From numpy-svn at scipy.org Tue Jul 1 10:22:46 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 1 Jul 2008 09:22:46 -0500 (CDT) Subject: [Numpy-svn] r5327 - branches/1.1.x/numpy/ma/tests Message-ID: <20080701142246.4424339C8B4@scipy.org> Author: pierregm Date: 2008-07-01 09:22:42 -0500 (Tue, 01 Jul 2008) New Revision: 5327 Modified: branches/1.1.x/numpy/ma/tests/test_mrecords.py Log: deleted the "reload" statement that shouldn't have been there Modified: branches/1.1.x/numpy/ma/tests/test_mrecords.py =================================================================== --- branches/1.1.x/numpy/ma/tests/test_mrecords.py 2008-06-30 14:55:14 UTC (rev 5326) +++ branches/1.1.x/numpy/ma/tests/test_mrecords.py 2008-07-01 14:22:42 UTC (rev 5327) @@ -22,7 +22,7 @@ from numpy.ma import masked, nomask, getdata, getmaskarray import numpy.ma.mrecords -reload(numpy.ma.mrecords) + from numpy.ma.mrecords import MaskedRecords, mrecarray,\ fromarrays, fromtextfile, fromrecords, addfield From numpy-svn at scipy.org Tue Jul 1 11:20:25 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 1 Jul 2008 10:20:25 -0500 (CDT) Subject: [Numpy-svn] r5328 - trunk/numpy/testing Message-ID: <20080701152025.E048D39C64A@scipy.org> Author: alan.mcintyre Date: 2008-07-01 10:20:23 -0500 (Tue, 01 Jul 2008) New Revision: 5328 Modified: trunk/numpy/testing/nosetester.py Log: Customize behavior of nose doctests: - Adding "#random" to an expected output line will skip the comparison with actual output (but the command is still executed). - All doctests have the numpy module available in their execution context as "np". - Whitespace normalization is enabled for all doctests executed via nose. Doctests added to check that the above behaviors are available. Nose version check/message cleanup. Fix typo in doctest for NoseTester (was still referencing scipy.testing). Rewrapped comments/docstrings to 80 columns. Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-01 14:22:42 UTC (rev 5327) +++ trunk/numpy/testing/nosetester.py 2008-07-01 15:20:23 UTC (rev 5328) @@ -8,24 +8,111 @@ import re import warnings + +# Patches nose functionality to add NumPy-specific features +# Note: This class should only be instantiated if nose has already +# been successfully imported +class NoseCustomizer: + __patched = False + + def __init__(self): + if NoseCustomizer.__patched: + return + + NoseCustomizer.__patched = True + from nose.plugins import doctests as npd + from nose.util import src + import numpy + import doctest + + # second-chance checker; if the default comparison doesn't + # pass, then see if the expected output string contains flags that + # tell us to ignore the output + class NumpyDoctestOutputChecker(doctest.OutputChecker): + def check_output(self, want, got, optionflags): + ret = doctest.OutputChecker.check_output(self, want, got, + optionflags) + if not ret: + if "#random" in want: + return True + + return ret + + + # Subclass nose.plugins.doctests.DocTestCase to work around a bug in + # its constructor that blocks non-default arguments from being passed + # down into doctest.DocTestCase + class NumpyDocTestCase(npd.DocTestCase): + def __init__(self, test, optionflags=0, setUp=None, tearDown=None, + checker=None, obj=None, result_var='_'): + self._result_var = result_var + self._nose_obj = obj + doctest.DocTestCase.__init__(self, test, + optionflags=optionflags, + setUp=setUp, tearDown=tearDown, + checker=checker) + + + # This will replace the existing loadTestsFromModule method of + # nose.plugins.doctests.Doctest. It turns on whitespace normalization, + # adds an implicit "import numpy as np" for doctests, and adds a + # "#random" directive to allow executing a command while ignoring its + # output. + def loadTestsFromModule(self, module): + if not self.matches(module.__name__): + npd.log.debug("Doctest doesn't want module %s", module) + return + try: + tests = self.finder.find(module) + except AttributeError: + # nose allows module.__test__ = False; doctest does not and + # throws AttributeError + return + if not tests: + return + tests.sort() + module_file = src(module.__file__) + for test in tests: + if not test.examples: + continue + if not test.filename: + test.filename = module_file + + # implicit "import numpy as np" for all doctests + test.globs['np'] = numpy + + optionflags = doctest.NORMALIZE_WHITESPACE + yield NumpyDocTestCase(test, + optionflags=optionflags, + result_var=self.doctest_result_var, + checker=NumpyDoctestOutputChecker()) + + # Monkeypatch loadTestsFromModule + npd.Doctest.loadTestsFromModule = loadTestsFromModule + + def import_nose(): """ Import nose only when needed. """ fine_nose = True + minimum_nose_version = (0,10,0) try: import nose from nose.tools import raises except ImportError: fine_nose = False else: - nose_version = nose.__versioninfo__ - if nose_version[0] < 1 and nose_version[1] < 10: + if nose.__versioninfo__ < minimum_nose_version: fine_nose = False if not fine_nose: - raise ImportError('Need nose >=0.10 for tests - see ' - 'http://somethingaboutorange.com/mrl/projects/nose') + raise ImportError('Need nose >=%d.%d.%d for tests - see ' + 'http://somethingaboutorange.com/mrl/projects/nose' % + minimum_nose_version) + # nose was successfully imported; make customizations for doctests + NoseCustomizer() + return nose def run_module_suite(file_to_run = None): @@ -51,7 +138,7 @@ This class is made available as numpy.testing.Tester: - >>> from scipy.testing import Tester + >>> from numpy.testing import Tester >>> test = Tester().test """ @@ -203,12 +290,13 @@ nose = import_nose() - # Because nose currently discards the test result object, but we need to - # return it to the user, override TestProgram.runTests to retain the result + # Because nose currently discards the test result object, but we need + # to return it to the user, override TestProgram.runTests to retain + # the result class NumpyTestProgram(nose.core.TestProgram): def runTests(self): - """Run Tests. Returns true on success, false on failure, and sets - self.success to the same value. + """Run Tests. Returns true on success, false on failure, and + sets self.success to the same value. """ if self.testRunner is None: self.testRunner = nose.core.TextTestRunner(stream=self.config.stream, @@ -233,3 +321,34 @@ argv = self._test_argv(label, verbose, extra_argv) argv += ['--match', r'(?:^|[\\b_\\.%s-])[Bb]ench' % os.sep] return nose.run(argv=argv) + + +######################################################################## +# Doctests for NumPy-specific doctest modifications + +# try the #random directive on the output line +def check_random_directive(): + ''' + >>> 2+2 + #random: may vary on your system + ''' + +# check the implicit "import numpy as np" +def check_implicit_np(): + ''' + >>> np.array([1,2,3]) + array([1, 2, 3]) + ''' + +# there's some extraneous whitespace around the correct responses +def check_whitespace_enabled(): + ''' + # whitespace after the 3 + >>> 1+2 + 3 + + # whitespace before the 7 + >>> 3+4 + 7 + ''' + From numpy-svn at scipy.org Tue Jul 1 18:01:19 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 1 Jul 2008 17:01:19 -0500 (CDT) Subject: [Numpy-svn] r5329 - trunk/numpy/ma Message-ID: <20080701220119.2079B39C0F7@scipy.org> Author: pierregm Date: 2008-07-01 17:01:09 -0500 (Tue, 01 Jul 2008) New Revision: 5329 Modified: trunk/numpy/ma/core.py trunk/numpy/ma/testutils.py Log: prevent .reshape to update the whole __dict__ of the result, use ._update_from instead Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-01 15:20:23 UTC (rev 5328) +++ trunk/numpy/ma/core.py 2008-07-01 22:01:09 UTC (rev 5329) @@ -2015,7 +2015,7 @@ """ result = self._data.reshape(*s).view(type(self)) - result.__dict__.update(self.__dict__) + result._update_from(self) if result._mask is not nomask: result._mask = self._mask.copy() result._mask.shape = result.shape Modified: trunk/numpy/ma/testutils.py =================================================================== --- trunk/numpy/ma/testutils.py 2008-07-01 15:20:23 UTC (rev 5328) +++ trunk/numpy/ma/testutils.py 2008-07-01 22:01:09 UTC (rev 5329) @@ -99,7 +99,7 @@ # Case #4. arrays or equivalent if ((actual is masked) and not (desired is masked)) or \ ((desired is masked) and not (actual is masked)): - msg = build_err_msg([actual, desired], + msg = build_err_msg([actual, desired], err_msg, header='', names=('x', 'y')) raise ValueError(msg) actual = np.array(actual, copy=False, subok=True) From numpy-svn at scipy.org Tue Jul 1 21:15:14 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 1 Jul 2008 20:15:14 -0500 (CDT) Subject: [Numpy-svn] r5330 - trunk/numpy/core Message-ID: <20080702011514.EEF7D39C0F7@scipy.org> Author: alan.mcintyre Date: 2008-07-01 20:15:06 -0500 (Tue, 01 Jul 2008) New Revision: 5330 Modified: trunk/numpy/core/arrayprint.py trunk/numpy/core/defmatrix.py trunk/numpy/core/memmap.py trunk/numpy/core/numeric.py trunk/numpy/core/records.py Log: Update doctests to use the implicit "import numpy as np" made available to all doctests. Modified: trunk/numpy/core/arrayprint.py =================================================================== --- trunk/numpy/core/arrayprint.py 2008-07-01 22:01:09 UTC (rev 5329) +++ trunk/numpy/core/arrayprint.py 2008-07-02 01:15:06 UTC (rev 5330) @@ -218,9 +218,8 @@ Examples -------- - >>> import numpy as N - >>> x = N.array([1e-16,1,2,3]) - >>> print array2string(x,precision=2,separator=',',suppress_small=True) + >>> x = np.array([1e-16,1,2,3]) + >>> print np.core.array2string(x,precision=2,separator=',',suppress_small=True) [ 0., 1., 2., 3.] """ Modified: trunk/numpy/core/defmatrix.py =================================================================== --- trunk/numpy/core/defmatrix.py 2008-07-01 22:01:09 UTC (rev 5329) +++ trunk/numpy/core/defmatrix.py 2008-07-02 01:15:06 UTC (rev 5330) @@ -84,8 +84,7 @@ Examples -------- - >>> from numpy import array - >>> matrix_power(array([[0,1],[-1,0]]),10) + >>> np.linalg.matrix_power(np.array([[0,1],[-1,0]]),10) array([[-1, 0], [ 0, -1]]) """ @@ -149,7 +148,6 @@ Examples -------- - >>> import numpy as np >>> a = np.matrix('1 2; 3 4') >>> print a [[1 2] Modified: trunk/numpy/core/memmap.py =================================================================== --- trunk/numpy/core/memmap.py 2008-07-01 22:01:09 UTC (rev 5329) +++ trunk/numpy/core/memmap.py 2008-07-02 01:15:06 UTC (rev 5330) @@ -67,7 +67,6 @@ Examples -------- - >>> import numpy as np >>> data = np.arange(12, dtype='float32') >>> data.resize((3,4)) Modified: trunk/numpy/core/numeric.py =================================================================== --- trunk/numpy/core/numeric.py 2008-07-01 22:01:09 UTC (rev 5329) +++ trunk/numpy/core/numeric.py 2008-07-02 01:15:06 UTC (rev 5330) @@ -214,8 +214,7 @@ is a sequence of indices into a. This sequence must be converted to a tuple in order to be used to index into a. - >>> from numpy import ones, argwhere - >>> argwhere(ones((2, 2))) + >>> np.argwhere(np.ones((2, 2))) array([[0, 0], [0, 1], [1, 0], @@ -228,10 +227,9 @@ Equivalent to a.ravel().nonzero()[0] - >>> from numpy import arange, flatnonzero - >>> arange(-2, 3) + >>> np.arange(-2, 3) array([-2, -1, 0, 1, 2]) - >>> flatnonzero(arange(-2, 3)) + >>> np.flatnonzero(np.arange(-2, 3)) array([0, 1, 3, 4]) """ return a.ravel().nonzero()[0] @@ -385,10 +383,9 @@ """Roll the elements in the array by 'shift' positions along the given axis. - >>> from numpy import roll - >>> arange(10) + >>> np.arange(10) array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - >>> roll(arange(10), 2) + >>> np.roll(np.arange(10), 2) array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7]) """ a = asanyarray(a) @@ -409,13 +406,12 @@ def rollaxis(a, axis, start=0): """Return transposed array so that axis is rolled before start. - >>> from numpy import ones, rollaxis - >>> a = ones((3,4,5,6)) - >>> rollaxis(a, 3, 1).shape + >>> a = np.ones((3,4,5,6)) + >>> np.rollaxis(a, 3, 1).shape (3, 6, 4, 5) - >>> rollaxis(a, 2, 0).shape + >>> np.rollaxis(a, 2, 0).shape (5, 3, 4, 6) - >>> rollaxis(a, 1, 4).shape + >>> np.rollaxis(a, 1, 4).shape (3, 5, 6, 4) """ n = a.ndim Modified: trunk/numpy/core/records.py =================================================================== --- trunk/numpy/core/records.py 2008-07-01 22:01:09 UTC (rev 5329) +++ trunk/numpy/core/records.py 2008-07-02 01:15:06 UTC (rev 5330) @@ -347,11 +347,10 @@ names=None, titles=None, aligned=False, byteorder=None): """ create a record array from a (flat) list of arrays - >>> import numpy as N - >>> x1=N.array([1,2,3,4]) - >>> x2=N.array(['a','dd','xyz','12']) - >>> x3=N.array([1.1,2,3,4]) - >>> r = fromarrays([x1,x2,x3],names='a,b,c') + >>> x1=np.array([1,2,3,4]) + >>> x2=np.array(['a','dd','xyz','12']) + >>> x3=np.array([1.1,2,3,4]) + >>> r = np.core.records.fromarrays([x1,x2,x3],names='a,b,c') >>> print r[1] (2, 'dd', 2.0) >>> x1[1]=34 @@ -515,8 +514,7 @@ to be a file object. >>> from tempfile import TemporaryFile - >>> import numpy as N - >>> a = N.empty(10,dtype='f8,i4,a5') + >>> a = np.empty(10,dtype='f8,i4,a5') >>> a[5] = (0.5,10,'abcde') >>> >>> fd=TemporaryFile() @@ -524,7 +522,7 @@ >>> a.tofile(fd) >>> >>> fd.seek(0) - >>> r=fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<') + >>> r=np.fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<') >>> print r[5] (0.5, 10, 'abcde') >>> r.shape From numpy-svn at scipy.org Tue Jul 1 23:15:49 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 1 Jul 2008 22:15:49 -0500 (CDT) Subject: [Numpy-svn] r5331 - trunk/numpy/core Message-ID: <20080702031549.CFCE739C344@scipy.org> Author: alan.mcintyre Date: 2008-07-01 22:15:46 -0500 (Tue, 01 Jul 2008) New Revision: 5331 Modified: trunk/numpy/core/fromnumeric.py trunk/numpy/core/numerictypes.py trunk/numpy/core/records.py Log: Update doctests to use the implicit "import numpy as np" made available to all doctests. Update doctests to use fully qualified names. Fixed typo in numerictypes.py: english_lower doctest has an example using english_upper Modified: trunk/numpy/core/fromnumeric.py =================================================================== --- trunk/numpy/core/fromnumeric.py 2008-07-02 01:15:06 UTC (rev 5330) +++ trunk/numpy/core/fromnumeric.py 2008-07-02 03:15:46 UTC (rev 5331) @@ -246,9 +246,8 @@ Examples -------- - >>> import numpy - >>> x = numpy.arange(5) - >>> numpy.put(x,[0,2,4],[-1,-2,-3]) + >>> x = np.arange(5) + >>> np.put(x,[0,2,4],[-1,-2,-3]) >>> print x [-1 1 -2 3 -3] @@ -270,21 +269,20 @@ Examples -------- - >>> import numpy - >>> x = numpy.array([[1,2,3]]) - >>> numpy.swapaxes(x,0,1) + >>> x = np.array([[1,2,3]]) + >>> np.swapaxes(x,0,1) array([[1], [2], [3]]) - >>> x = numpy.array([[[0,1],[2,3]],[[4,5],[6,7]]]) + >>> x = np.array([[[0,1],[2,3]],[[4,5],[6,7]]]) >>> x array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) - >>> numpy.swapaxes(x,0,2) + >>> np.swapaxes(x,0,2) array([[[0, 4], [2, 6]], @@ -312,17 +310,16 @@ Examples -------- - >>> import numpy - >>> x = numpy.arange(4).reshape((2,2)) + >>> x = np.arange(4).reshape((2,2)) >>> x array([[0, 1], [2, 3]]) - >>> numpy.transpose(x) + >>> np.transpose(x) array([[0, 2], [1, 3]]) - >>> numpy.transpose(x,(0,1)) # no change, axes are kept in current order + >>> np.transpose(x,(0,1)) # no change, axes are kept in current order array([[0, 1], [2, 3]]) @@ -474,13 +471,12 @@ Examples -------- - >>> from numpy import * - >>> a = arange(6).reshape(2,3) - >>> argmax(a) + >>> a = np.arange(6).reshape(2,3) + >>> np.argmax(a) 5 - >>> argmax(a,0) + >>> np.argmax(a,0) array([1, 1, 1]) - >>> argmax(a,1) + >>> np.argmax(a,1) array([2, 2]) """ @@ -508,13 +504,12 @@ Examples -------- - >>> from numpy import * - >>> a = arange(6).reshape(2,3) - >>> argmin(a) + >>> a = np.arange(6).reshape(2,3) + >>> np.argmin(a) 0 - >>> argmin(a,0) + >>> np.argmin(a,0) array([0, 0, 0]) - >>> argmin(a,1) + >>> np.argmin(a,1) array([0, 0]) """ @@ -682,8 +677,7 @@ Examples -------- - >>> from numpy import * - >>> a = arange(4).reshape(2,2) + >>> a = np.arange(4).reshape(2,2) >>> a array([[0, 1], [2, 3]]) @@ -692,10 +686,11 @@ >>> a.diagonal(1) array([1]) - >>> a = arange(8).reshape(2,2,2) + >>> a = np.arange(8).reshape(2,2,2) >>> a array([[[0, 1], [2, 3]], + [[4, 5], [6, 7]]]) >>> a.diagonal(0,-2,-1) @@ -748,11 +743,10 @@ Examples -------- - >>> from numpy import * - >>> trace(eye(3)) + >>> np.trace(np.eye(3)) 3.0 - >>> a = arange(8).reshape((2,2,2)) - >>> trace(a) + >>> a = np.arange(8).reshape((2,2,2)) + >>> np.trace(a) array([6, 8]) """ @@ -784,8 +778,7 @@ Examples -------- - >>> from numpy import * - >>> x = array([[1,2,3],[4,5,6]]) + >>> x = np.array([[1,2,3],[4,5,6]]) >>> x array([[1, 2, 3], [4, 5, 6]]) @@ -809,12 +802,11 @@ Examples -------- - >>> from numpy import * - >>> eye(3)[nonzero(eye(3))] + >>> np.eye(3)[np.nonzero(np.eye(3))] array([ 1., 1., 1.]) - >>> nonzero(eye(3)) + >>> np.nonzero(np.eye(3)) (array([0, 1, 2]), array([0, 1, 2])) - >>> eye(3)[nonzero(eye(3))] + >>> np.eye(3)[np.nonzero(np.eye(3))] array([ 1., 1., 1.]) """ @@ -844,10 +836,9 @@ Examples -------- - >>> from numpy import * - >>> shape(eye(3)) + >>> np.shape(np.eye(3)) (3, 3) - >>> shape([[1,2]]) + >>> np.shape([[1,2]]) (1, 2) """ @@ -882,14 +873,13 @@ Examples -------- - >>> import numpy - >>> a = numpy.array([[1, 2], [3, 4]]) - >>> numpy.compress([0, 1], a, axis=0) + >>> a = np.array([[1, 2], [3, 4]]) + >>> np.compress([0, 1], a, axis=0) array([[3, 4]]) - >>> numpy.compress([1], a, axis=1) + >>> np.compress([1], a, axis=1) array([[1], [3]]) - >>> numpy.compress([0,1,1], a) + >>> np.compress([0,1,1], a) array([2, 3]) """ @@ -923,13 +913,12 @@ Examples -------- - >>> import numpy - >>> a = numpy.arange(10) - >>> numpy.clip(a, 1, 8) + >>> a = np.arange(10) + >>> np.clip(a, 1, 8) array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8]) >>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - >>> numpy.clip(a, 3, 6, out=a) + >>> np.clip(a, 3, 6, out=a) array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6]) >>> a array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6]) @@ -976,16 +965,15 @@ Examples -------- - >>> from numpy import * - >>> sum([0.5, 1.5]) + >>> np.sum([0.5, 1.5]) 2.0 - >>> sum([0.5, 1.5], dtype=int32) + >>> np.sum([0.5, 1.5], dtype=np.int32) 1 - >>> sum([[0, 1], [0, 5]]) + >>> np.sum([[0, 1], [0, 5]]) 6 - >>> sum([[0, 1], [0, 5]], axis=1) + >>> np.sum([[0, 1], [0, 5]], axis=1) array([1, 5]) - >>> ones(128, dtype=int8).sum(dtype=int8) # overflow! + >>> np.ones(128, dtype=np.int8).sum(dtype=np.int8) # overflow! -128 Notes @@ -1042,14 +1030,13 @@ Examples -------- - >>> from numpy import * - >>> product([1.,2.]) + >>> np.product([1.,2.]) 2.0 - >>> product([1.,2.], dtype=int32) + >>> np.product([1.,2.], dtype=np.int32) 2 - >>> product([[1.,2.],[3.,4.]]) + >>> np.product([[1.,2.],[3.,4.]]) 24.0 - >>> product([[1.,2.],[3.,4.]], axis=1) + >>> np.product([[1.,2.],[3.,4.]], axis=1) array([ 2., 12.]) Notes @@ -1088,12 +1075,11 @@ Examples -------- - >>> import numpy - >>> b = numpy.array([True, False, True, True]) - >>> numpy.sometrue(b) + >>> b = np.array([True, False, True, True]) + >>> np.sometrue(b) True - >>> a = numpy.array([1, 5, 2, 7]) - >>> numpy.sometrue(a >= 5) + >>> a = np.array([1, 5, 2, 7]) + >>> np.sometrue(a >= 5) True """ @@ -1221,16 +1207,15 @@ Examples -------- - >>> import numpy - >>> a=numpy.array([[1,2,3],[4,5,6]]) - >>> numpy.cumsum(a) # cumulative sum = intermediate summing results & total sum. Default axis=None results in raveling the array first. + >>> a=np.array([[1,2,3],[4,5,6]]) + >>> np.cumsum(a) # cumulative sum = intermediate summing results & total sum. Default axis=None results in raveling the array first. array([ 1, 3, 6, 10, 15, 21]) - >>> numpy.cumsum(a,dtype=float) # specifies type of output value(s) + >>> np.cumsum(a,dtype=float) # specifies type of output value(s) array([ 1., 3., 6., 10., 15., 21.]) - >>> numpy.cumsum(a,axis=0) # sum over rows for each of the 3 columns + >>> np.cumsum(a,axis=0) # sum over rows for each of the 3 columns array([[1, 2, 3], [5, 7, 9]]) - >>> numpy.cumsum(a,axis=1) # sum over columns for each of the 2 rows + >>> np.cumsum(a,axis=1) # sum over columns for each of the 2 rows array([[ 1, 3, 6], [ 4, 9, 15]]) @@ -1281,14 +1266,13 @@ Examples -------- - >>> import numpy - >>> x = numpy.arange(4).reshape((2,2)) + >>> x = np.arange(4).reshape((2,2)) >>> x array([[0, 1], [2, 3]]) - >>> numpy.ptp(x,0) + >>> np.ptp(x,0) array([2, 2]) - >>> numpy.ptp(x,1) + >>> np.ptp(x,1) array([1, 1]) """ @@ -1320,14 +1304,13 @@ Examples -------- - >>> import numpy - >>> x = numpy.arange(4).reshape((2,2)) + >>> x = np.arange(4).reshape((2,2)) >>> x array([[0, 1], [2, 3]]) - >>> numpy.amax(x,0) + >>> np.amax(x,0) array([2, 3]) - >>> numpy.amax(x,1) + >>> np.amax(x,1) array([1, 3]) """ @@ -1359,14 +1342,13 @@ Examples -------- - >>> import numpy - >>> x = numpy.arange(4).reshape((2,2)) + >>> x = np.arange(4).reshape((2,2)) >>> x array([[0, 1], [2, 3]]) - >>> numpy.amin(x,0) + >>> np.amin(x,0) array([0, 1]) - >>> numpy.amin(x,1) + >>> np.amin(x,1) array([0, 2]) """ @@ -1393,11 +1375,10 @@ Examples -------- - >>> import numpy - >>> z = numpy.zeros((7,4,5)) + >>> z = np.zeros((7,4,5)) >>> z.shape[0] 7 - >>> numpy.alen(z) + >>> np.alen(z) 7 """ @@ -1442,14 +1423,13 @@ Examples -------- - >>> from numpy import * - >>> prod([1.,2.]) + >>> np.prod([1.,2.]) 2.0 - >>> prod([1.,2.], dtype=int32) + >>> np.prod([1.,2.], dtype=np.int32) 2 - >>> prod([[1.,2.],[3.,4.]]) + >>> np.prod([[1.,2.],[3.,4.]]) 24.0 - >>> prod([[1.,2.],[3.,4.]], axis=1) + >>> np.prod([[1.,2.],[3.,4.]], axis=1) array([ 2., 12.]) Notes @@ -1503,20 +1483,19 @@ Examples -------- - >>> import numpy - >>> a=numpy.array([[1,2,3],[4,5,6]]) - >>> a=numpy.array([1,2,3]) - >>> numpy.cumprod(a) # intermediate results 1, 1*2 + >>> a=np.array([[1,2,3],[4,5,6]]) + >>> a=np.array([1,2,3]) + >>> np.cumprod(a) # intermediate results 1, 1*2 ... # total product 1*2*3 = 6 array([1, 2, 6]) - >>> a=numpy.array([[1,2,3],[4,5,6]]) - >>> numpy.cumprod(a,dtype=float) # specify type of output + >>> a=np.array([[1,2,3],[4,5,6]]) + >>> np.cumprod(a,dtype=float) # specify type of output array([ 1., 2., 6., 24., 120., 720.]) - >>> numpy.cumprod(a,axis=0) # for each of the 3 columns: + >>> np.cumprod(a,axis=0) # for each of the 3 columns: ... # product and intermediate results array([[ 1, 2, 3], [ 4, 10, 18]]) - >>> numpy.cumprod(a,axis=1) # for each of the two rows: + >>> np.cumprod(a,axis=1) # for each of the two rows: ... # product and intermediate results array([[ 1, 2, 6], [ 4, 20, 120]]) @@ -1555,11 +1534,11 @@ Examples -------- - >>> ndim([[1,2,3],[4,5,6]]) + >>> np.ndim([[1,2,3],[4,5,6]]) 2 - >>> ndim(array([[1,2,3],[4,5,6]])) + >>> np.ndim(array([[1,2,3],[4,5,6]])) 2 - >>> ndim(1) + >>> np.ndim(1) 0 """ @@ -1596,11 +1575,11 @@ Examples -------- - >>> rank([[1,2,3],[4,5,6]]) + >>> np.rank([[1,2,3],[4,5,6]]) 2 - >>> rank(array([[1,2,3],[4,5,6]])) + >>> np.rank(np.array([[1,2,3],[4,5,6]])) 2 - >>> rank(1) + >>> np.rank(1) 0 """ @@ -1635,12 +1614,12 @@ Examples -------- - >>> a = array([[1,2,3],[4,5,6]]) - >>> size(a) + >>> a = np.array([[1,2,3],[4,5,6]]) + >>> np.size(a) 6 - >>> size(a,1) + >>> np.size(a,1) 3 - >>> size(a,0) + >>> np.size(a,0) 2 """ @@ -1698,11 +1677,11 @@ Examples -------- - >>> around([.5, 1.5, 2.5, 3.5, 4.5]) + >>> np.around([.5, 1.5, 2.5, 3.5, 4.5]) array([ 0., 2., 2., 4., 4.]) - >>> around([1,2,3,11], decimals=1) + >>> np.around([1,2,3,11], decimals=1) array([ 1, 2, 3, 11]) - >>> around([1,2,3,11], decimals=-1) + >>> np.around([1,2,3,11], decimals=-1) array([ 0, 0, 0, 10]) """ @@ -1755,11 +1734,11 @@ Examples -------- - >>> round_([.5, 1.5, 2.5, 3.5, 4.5]) + >>> np.round_([.5, 1.5, 2.5, 3.5, 4.5]) array([ 0., 2., 2., 4., 4.]) - >>> round_([1,2,3,11], decimals=1) + >>> np.round_([1,2,3,11], decimals=1) array([ 1, 2, 3, 11]) - >>> round_([1,2,3,11], decimals=-1) + >>> np.round_([1,2,3,11], decimals=-1) array([ 0, 0, 0, 10]) """ @@ -1811,12 +1790,12 @@ Examples -------- - >>> a = array([[1,2],[3,4]]) - >>> mean(a) + >>> a = np.array([[1,2],[3,4]]) + >>> np.mean(a) 2.5 - >>> mean(a,0) + >>> np.mean(a,0) array([ 2., 3.]) - >>> mean(a,1) + >>> np.mean(a,1) array([ 1.5, 3.5]) """ @@ -1876,12 +1855,12 @@ Examples -------- - >>> a = array([[1,2],[3,4]]) - >>> std(a) + >>> a = np.array([[1,2],[3,4]]) + >>> np.std(a) 1.1180339887498949 - >>> std(a,0) + >>> np.std(a,0) array([ 1., 1.]) - >>> std(a,1) + >>> np.std(a,1) array([ 0.5, 0.5]) """ @@ -1940,12 +1919,12 @@ Examples -------- - >>> a = array([[1,2],[3,4]]) - >>> var(a) + >>> a = np.array([[1,2],[3,4]]) + >>> np.var(a) 1.25 - >>> var(a,0) + >>> np.var(a,0) array([ 1., 1.]) - >>> var(a,1) + >>> np.var(a,1) array([ 0.25, 0.25]) """ Modified: trunk/numpy/core/numerictypes.py =================================================================== --- trunk/numpy/core/numerictypes.py 2008-07-02 01:15:06 UTC (rev 5330) +++ trunk/numpy/core/numerictypes.py 2008-07-02 03:15:46 UTC (rev 5331) @@ -113,7 +113,7 @@ >>> from numpy.core.numerictypes import english_lower >>> english_lower('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_') 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_' - >>> english_upper('') + >>> english_lower('') '' """ lowered = s.translate(LOWER_TABLE) Modified: trunk/numpy/core/records.py =================================================================== --- trunk/numpy/core/records.py 2008-07-02 01:15:06 UTC (rev 5330) +++ trunk/numpy/core/records.py 2008-07-02 03:15:46 UTC (rev 5331) @@ -428,7 +428,8 @@ If formats is None, then this will auto-detect formats. Use list of tuples rather than list of lists for faster processing. - >>> r=fromrecords([(456,'dbe',1.2),(2,'de',1.3)],names='col1,col2,col3') + >>> r=np.core.records.fromrecords([(456,'dbe',1.2),(2,'de',1.3)], + ... names='col1,col2,col3') >>> print r[0] (456, 'dbe', 1.2) >>> r.col1 @@ -522,7 +523,8 @@ >>> a.tofile(fd) >>> >>> fd.seek(0) - >>> r=np.fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<') + >>> r=np.core.records.fromfile(fd, formats='f8,i4,a5', shape=10, + ... byteorder='<') >>> print r[5] (0.5, 10, 'abcde') >>> r.shape From numpy-svn at scipy.org Wed Jul 2 17:46:13 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 2 Jul 2008 16:46:13 -0500 (CDT) Subject: [Numpy-svn] r5332 - in trunk/numpy/ma: . tests Message-ID: <20080702214613.88E4639C228@scipy.org> Author: pierregm Date: 2008-07-02 16:46:01 -0500 (Wed, 02 Jul 2008) New Revision: 5332 Modified: trunk/numpy/ma/core.py trunk/numpy/ma/tests/test_extras.py Log: Corrected a goof in .reshape() Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-02 03:15:46 UTC (rev 5331) +++ trunk/numpy/ma/core.py 2008-07-02 21:46:01 UTC (rev 5332) @@ -2016,9 +2016,9 @@ """ result = self._data.reshape(*s).view(type(self)) result._update_from(self) - if result._mask is not nomask: - result._mask = self._mask.copy() - result._mask.shape = result.shape + mask = self._mask + if mask is not nomask: + result._mask = mask.reshape(*s) return result # def resize(self, newshape, refcheck=True, order=False): Modified: trunk/numpy/ma/tests/test_extras.py =================================================================== --- trunk/numpy/ma/tests/test_extras.py 2008-07-02 03:15:46 UTC (rev 5331) +++ trunk/numpy/ma/tests/test_extras.py 2008-07-02 21:46:01 UTC (rev 5332) @@ -51,9 +51,9 @@ assert_equal(average(y, axis=1), [average(x,axis=0), average(x,axis=0) * 2.0]) assert_equal(average(y, None, weights=w2), 20./6.) - assert_equal(average(y, axis=0, weights=w2), + assert_equal(average(y, axis=0, weights=w2), [0.,1.,2.,3.,4.,10.]) - assert_equal(average(y, axis=1), + assert_equal(average(y, axis=1), [average(x,axis=0), average(x,axis=0) * 2.0]) m1 = zeros(6) m2 = [0,0,1,1,0,0] From numpy-svn at scipy.org Wed Jul 2 22:23:37 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 2 Jul 2008 21:23:37 -0500 (CDT) Subject: [Numpy-svn] r5333 - trunk/numpy/core Message-ID: <20080703022337.7CD9139C343@scipy.org> Author: alan.mcintyre Date: 2008-07-02 21:23:34 -0500 (Wed, 02 Jul 2008) New Revision: 5333 Modified: trunk/numpy/core/fromnumeric.py trunk/numpy/core/numeric.py Log: Update doctests to assume only an "import numpy as np" has been executed prior to the example code. Updated numeric.py doctests to skip with-statements, and updated expected outputs to match current NumPy behavior. Modified: trunk/numpy/core/fromnumeric.py =================================================================== --- trunk/numpy/core/fromnumeric.py 2008-07-02 21:46:01 UTC (rev 5332) +++ trunk/numpy/core/fromnumeric.py 2008-07-03 02:23:34 UTC (rev 5333) @@ -155,11 +155,11 @@ >>> choices = [[0, 1, 2, 3], [10, 11, 12, 13], ... [20, 21, 22, 23], [30, 31, 32, 33]] - >>> choose([2, 3, 1, 0], choices) + >>> np.choose([2, 3, 1, 0], choices) array([20, 31, 12, 3]) - >>> choose([2, 4, 1, 0], choices, mode='clip') + >>> np.choose([2, 4, 1, 0], choices, mode='clip') array([20, 31, 12, 3]) - >>> choose([2, 4, 1, 0], choices, mode='wrap') + >>> np.choose([2, 4, 1, 0], choices, mode='wrap') array([20, 1, 12, 3]) """ @@ -197,13 +197,13 @@ Examples -------- - >>> x = array([[1,2],[3,4]]) - >>> repeat(x, 2) + >>> x = np.array([[1,2],[3,4]]) + >>> np.repeat(x, 2) array([1, 1, 2, 2, 3, 3, 4, 4]) - >>> repeat(x, 3, axis=1) + >>> np.repeat(x, 3, axis=1) array([[1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4]]) - >>> repeat(x, [1, 2], axis=0) + >>> np.repeat(x, [1, 2], axis=0) array([[1, 2], [3, 4], [3, 4]]) @@ -560,7 +560,7 @@ Examples -------- - >>> searchsorted([1,2,3,4,5],[6,4,0]) + >>> np.searchsorted([1,2,3,4,5],[6,4,0]) array([5, 3, 0]) """ @@ -624,10 +624,10 @@ Examples -------- - >>> x = array([[[1,1,1],[2,2,2],[3,3,3]]]) + >>> x = np.array([[[1,1,1],[2,2,2],[3,3,3]]]) >>> x.shape (1, 3, 3) - >>> squeeze(x).shape + >>> np.squeeze(x).shape (3, 3) """ @@ -782,7 +782,7 @@ >>> x array([[1, 2, 3], [4, 5, 6]]) - >>> ravel(x) + >>> np.ravel(x) array([1, 2, 3, 4, 5, 6]) """ @@ -1536,7 +1536,7 @@ -------- >>> np.ndim([[1,2,3],[4,5,6]]) 2 - >>> np.ndim(array([[1,2,3],[4,5,6]])) + >>> np.ndim(np.array([[1,2,3],[4,5,6]])) 2 >>> np.ndim(1) 0 Modified: trunk/numpy/core/numeric.py =================================================================== --- trunk/numpy/core/numeric.py 2008-07-02 21:46:01 UTC (rev 5332) +++ trunk/numpy/core/numeric.py 2008-07-03 02:23:34 UTC (rev 5333) @@ -881,22 +881,23 @@ """with errstate(**state): --> operations in following block use given state. # Set error handling to known state. - >>> _ = seterr(invalid='raise', divide='raise', over='raise', under='ignore') + >>> _ = np.seterr(invalid='raise', divide='raise', over='raise', + ... under='ignore') - |>> a = -arange(3) - |>> with errstate(invalid='ignore'): - ... print sqrt(a) + >>> a = -np.arange(3) + >>> with np.errstate(invalid='ignore'): # doctest: +SKIP + ... print np.sqrt(a) # with statement requires Python 2.5 [ 0. -1.#IND -1.#IND] - |>> print sqrt(a.astype(complex)) - [ 0. +0.00000000e+00j 0. +1.00000000e+00j 0. +1.41421356e+00j] - |>> print sqrt(a) + >>> print np.sqrt(a.astype(complex)) + [ 0.+0.j 0.+1.j 0.+1.41421356j] + >>> print np.sqrt(a) Traceback (most recent call last): ... - FloatingPointError: invalid encountered in sqrt - |>> with errstate(divide='ignore'): + FloatingPointError: invalid value encountered in sqrt + >>> with np.errstate(divide='ignore'): # doctest: +SKIP ... print a/0 [0 0 0] - |>> print a/0 + >>> print a/0 Traceback (most recent call last): ... FloatingPointError: divide by zero encountered in divide From numpy-svn at scipy.org Wed Jul 2 22:35:02 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 2 Jul 2008 21:35:02 -0500 (CDT) Subject: [Numpy-svn] r5334 - trunk/numpy/testing Message-ID: <20080703023502.4DC5D39C089@scipy.org> Author: alan.mcintyre Date: 2008-07-02 21:34:59 -0500 (Wed, 02 Jul 2008) New Revision: 5334 Modified: trunk/numpy/testing/numpytest.py Log: Deprecate set_package_path, set_local_path, and restore_path. Modified: trunk/numpy/testing/numpytest.py =================================================================== --- trunk/numpy/testing/numpytest.py 2008-07-03 02:23:34 UTC (rev 5333) +++ trunk/numpy/testing/numpytest.py 2008-07-03 02:34:59 UTC (rev 5334) @@ -38,6 +38,9 @@ restore_path() """ + warnings.warn("set_package_path will be removed in NumPy 1.3; please " + "update your code", DeprecationWarning, stacklevel=2) + from distutils.util import get_platform f = get_frame(level) if f.f_locals['__name__']=='__main__': @@ -61,6 +64,9 @@ restore_path() """ + warnings.warn("set_local_path will be removed in NumPy 1.3; please " + "update your code", DeprecationWarning, stacklevel=2) + f = get_frame(level) if f.f_locals['__name__']=='__main__': testfile = sys.argv[0] @@ -72,8 +78,10 @@ sys.path.insert(0,local_path) return +def restore_path(): + warnings.warn("restore_path will be removed in NumPy 1.3; please " + "update your code", DeprecationWarning, stacklevel=2) -def restore_path(): if DEBUG: print 'Removing %r from sys.path' % (sys.path[0]) del sys.path[0] From numpy-svn at scipy.org Wed Jul 2 22:49:07 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 2 Jul 2008 21:49:07 -0500 (CDT) Subject: [Numpy-svn] r5335 - trunk/numpy/core/tests Message-ID: <20080703024907.45DF939C089@scipy.org> Author: alan.mcintyre Date: 2008-07-02 21:49:02 -0500 (Wed, 02 Jul 2008) New Revision: 5335 Modified: trunk/numpy/core/tests/test_defmatrix.py trunk/numpy/core/tests/test_numeric.py trunk/numpy/core/tests/test_numerictypes.py trunk/numpy/core/tests/test_records.py trunk/numpy/core/tests/test_regression.py trunk/numpy/core/tests/test_scalarmath.py trunk/numpy/core/tests/test_umath.py trunk/numpy/core/tests/test_unicode.py Log: Remove uses of set_package_path, set_local_path, restore_path. Clean up and (somewhat) standardize test module imports. In test_scalararray.py and test_defmatrix.py, update tests that are commented out so that they will be picked up in case they are ever uncommented. Modified: trunk/numpy/core/tests/test_defmatrix.py =================================================================== --- trunk/numpy/core/tests/test_defmatrix.py 2008-07-03 02:34:59 UTC (rev 5334) +++ trunk/numpy/core/tests/test_defmatrix.py 2008-07-03 02:49:02 UTC (rev 5335) @@ -1,9 +1,7 @@ import sys from numpy.testing import * -set_package_path() from numpy.core import * import numpy as np -restore_path() class TestCtor(TestCase): def test_basic(self): @@ -216,11 +214,11 @@ assert isinstance(x, matrix) assert_equal(x, matrix([[4, 3], [1, 2]])) -## def check_vector_element(self): -## x = matrix([[1,2,3],[4,5,6]]) -## assert_equal(x[0][0],1) -## assert_equal(x[0].shape,(1,3)) -## assert_equal(x[:,0].shape,(2,1)) +# def test_vector_element(self): +# x = matrix([[1,2,3],[4,5,6]]) +# assert_equal(x[0][0],1) +# assert_equal(x[0].shape,(1,3)) +# assert_equal(x[:,0].shape,(2,1)) def test_matrix_element(self): x = matrix([[1,2,3],[4,5,6]]) Modified: trunk/numpy/core/tests/test_numeric.py =================================================================== --- trunk/numpy/core/tests/test_numeric.py 2008-07-03 02:34:59 UTC (rev 5334) +++ trunk/numpy/core/tests/test_numeric.py 2008-07-03 02:49:02 UTC (rev 5335) @@ -291,17 +291,16 @@ return (randn(n, m)).astype(float32) def _neg_byteorder(self, a): - import sys - a = asarray(a) + a = asarray(a) if sys.byteorder == 'little': - a = a.astype(a.dtype.newbyteorder('>')) + a = a.astype(a.dtype.newbyteorder('>')) else: - a = a.astype(a.dtype.newbyteorder('<')) + a = a.astype(a.dtype.newbyteorder('<')) return a def _generate_non_native_data(self, n, m): - data = randn(n, m) - data = self._neg_byteorder(data) + data = randn(n, m) + data = self._neg_byteorder(data) assert not data.dtype.isnative return data Modified: trunk/numpy/core/tests/test_numerictypes.py =================================================================== --- trunk/numpy/core/tests/test_numerictypes.py 2008-07-03 02:34:59 UTC (rev 5334) +++ trunk/numpy/core/tests/test_numerictypes.py 2008-07-03 02:49:02 UTC (rev 5335) @@ -1,7 +1,6 @@ import sys from numpy.testing import * -import numpy -from numpy import zeros, ones, array +import numpy as np # This is the structure of the table used for plain objects: # @@ -103,33 +102,33 @@ def test_zeros0D(self): """Check creation of 0-dimensional objects""" - h = zeros((), dtype=self._descr) + h = np.zeros((), dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) self.assert_(h.dtype.fields['x'][0].name[:4] == 'void') self.assert_(h.dtype.fields['x'][0].char == 'V') - self.assert_(h.dtype.fields['x'][0].type == numpy.void) + self.assert_(h.dtype.fields['x'][0].type == np.void) # A small check that data is ok - assert_equal(h['z'], zeros((), dtype='u1')) + assert_equal(h['z'], np.zeros((), dtype='u1')) def test_zerosSD(self): """Check creation of single-dimensional objects""" - h = zeros((2,), dtype=self._descr) + h = np.zeros((2,), dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) self.assert_(h.dtype['y'].name[:4] == 'void') self.assert_(h.dtype['y'].char == 'V') - self.assert_(h.dtype['y'].type == numpy.void) + self.assert_(h.dtype['y'].type == np.void) # A small check that data is ok - assert_equal(h['z'], zeros((2,), dtype='u1')) + assert_equal(h['z'], np.zeros((2,), dtype='u1')) def test_zerosMD(self): """Check creation of multi-dimensional objects""" - h = zeros((2,3), dtype=self._descr) + h = np.zeros((2,3), dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) self.assert_(h.dtype['z'].name == 'uint8') self.assert_(h.dtype['z'].char == 'B') - self.assert_(h.dtype['z'].type == numpy.uint8) + self.assert_(h.dtype['z'].type == np.uint8) # A small check that data is ok - assert_equal(h['z'], zeros((2,3), dtype='u1')) + assert_equal(h['z'], np.zeros((2,3), dtype='u1')) class test_create_zeros_plain(create_zeros, TestCase): @@ -146,7 +145,7 @@ def test_tuple(self): """Check creation from tuples""" - h = array(self._buffer, dtype=self._descr) + h = np.array(self._buffer, dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) if self.multiple_rows: self.assert_(h.shape == (2,)) @@ -155,7 +154,7 @@ def test_list_of_tuple(self): """Check creation from list of tuples""" - h = array([self._buffer], dtype=self._descr) + h = np.array([self._buffer], dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) if self.multiple_rows: self.assert_(h.shape == (1,2)) @@ -164,7 +163,7 @@ def test_list_of_list_of_tuple(self): """Check creation from list of list of tuples""" - h = array([[self._buffer]], dtype=self._descr) + h = np.array([[self._buffer]], dtype=self._descr) self.assert_(normalize_descr(self._descr) == h.dtype.descr) if self.multiple_rows: self.assert_(h.shape == (1,1,2)) @@ -205,19 +204,19 @@ """Check the reading of values in heterogeneous arrays (plain)""" def test_access_fields(self): - h = array(self._buffer, dtype=self._descr) + h = np.array(self._buffer, dtype=self._descr) if not self.multiple_rows: self.assert_(h.shape == ()) - assert_equal(h['x'], array(self._buffer[0], dtype='i4')) - assert_equal(h['y'], array(self._buffer[1], dtype='f8')) - assert_equal(h['z'], array(self._buffer[2], dtype='u1')) + assert_equal(h['x'], np.array(self._buffer[0], dtype='i4')) + assert_equal(h['y'], np.array(self._buffer[1], dtype='f8')) + assert_equal(h['z'], np.array(self._buffer[2], dtype='u1')) else: self.assert_(len(h) == 2) - assert_equal(h['x'], array([self._buffer[0][0], + assert_equal(h['x'], np.array([self._buffer[0][0], self._buffer[1][0]], dtype='i4')) - assert_equal(h['y'], array([self._buffer[0][1], + assert_equal(h['y'], np.array([self._buffer[0][1], self._buffer[1][1]], dtype='f8')) - assert_equal(h['z'], array([self._buffer[0][2], + assert_equal(h['z'], np.array([self._buffer[0][2], self._buffer[1][2]], dtype='u1')) @@ -239,73 +238,73 @@ def test_access_top_fields(self): """Check reading the top fields of a nested array""" - h = array(self._buffer, dtype=self._descr) + h = np.array(self._buffer, dtype=self._descr) if not self.multiple_rows: self.assert_(h.shape == ()) - assert_equal(h['x'], array(self._buffer[0], dtype='i4')) - assert_equal(h['y'], array(self._buffer[4], dtype='f8')) - assert_equal(h['z'], array(self._buffer[5], dtype='u1')) + assert_equal(h['x'], np.array(self._buffer[0], dtype='i4')) + assert_equal(h['y'], np.array(self._buffer[4], dtype='f8')) + assert_equal(h['z'], np.array(self._buffer[5], dtype='u1')) else: self.assert_(len(h) == 2) - assert_equal(h['x'], array([self._buffer[0][0], - self._buffer[1][0]], dtype='i4')) - assert_equal(h['y'], array([self._buffer[0][4], - self._buffer[1][4]], dtype='f8')) - assert_equal(h['z'], array([self._buffer[0][5], - self._buffer[1][5]], dtype='u1')) + assert_equal(h['x'], np.array([self._buffer[0][0], + self._buffer[1][0]], dtype='i4')) + assert_equal(h['y'], np.array([self._buffer[0][4], + self._buffer[1][4]], dtype='f8')) + assert_equal(h['z'], np.array([self._buffer[0][5], + self._buffer[1][5]], dtype='u1')) + - def test_nested1_acessors(self): """Check reading the nested fields of a nested array (1st level)""" - h = array(self._buffer, dtype=self._descr) + h = np.array(self._buffer, dtype=self._descr) if not self.multiple_rows: assert_equal(h['Info']['value'], - array(self._buffer[1][0], dtype='c16')) + np.array(self._buffer[1][0], dtype='c16')) assert_equal(h['Info']['y2'], - array(self._buffer[1][1], dtype='f8')) + np.array(self._buffer[1][1], dtype='f8')) assert_equal(h['info']['Name'], - array(self._buffer[3][0], dtype='U2')) + np.array(self._buffer[3][0], dtype='U2')) assert_equal(h['info']['Value'], - array(self._buffer[3][1], dtype='c16')) + np.array(self._buffer[3][1], dtype='c16')) else: assert_equal(h['Info']['value'], - array([self._buffer[0][1][0], + np.array([self._buffer[0][1][0], self._buffer[1][1][0]], dtype='c16')) assert_equal(h['Info']['y2'], - array([self._buffer[0][1][1], + np.array([self._buffer[0][1][1], self._buffer[1][1][1]], dtype='f8')) assert_equal(h['info']['Name'], - array([self._buffer[0][3][0], + np.array([self._buffer[0][3][0], self._buffer[1][3][0]], dtype='U2')) assert_equal(h['info']['Value'], - array([self._buffer[0][3][1], + np.array([self._buffer[0][3][1], self._buffer[1][3][1]], dtype='c16')) def test_nested2_acessors(self): """Check reading the nested fields of a nested array (2nd level)""" - h = array(self._buffer, dtype=self._descr) + h = np.array(self._buffer, dtype=self._descr) if not self.multiple_rows: assert_equal(h['Info']['Info2']['value'], - array(self._buffer[1][2][1], dtype='c16')) + np.array(self._buffer[1][2][1], dtype='c16')) assert_equal(h['Info']['Info2']['z3'], - array(self._buffer[1][2][3], dtype='u4')) + np.array(self._buffer[1][2][3], dtype='u4')) else: assert_equal(h['Info']['Info2']['value'], - array([self._buffer[0][1][2][1], + np.array([self._buffer[0][1][2][1], self._buffer[1][1][2][1]], dtype='c16')) assert_equal(h['Info']['Info2']['z3'], - array([self._buffer[0][1][2][3], + np.array([self._buffer[0][1][2][3], self._buffer[1][1][2][3]], dtype='u4')) def test_nested1_descriptor(self): """Check access nested descriptors of a nested array (1st level)""" - h = array(self._buffer, dtype=self._descr) + h = np.array(self._buffer, dtype=self._descr) self.assert_(h.dtype['Info']['value'].name == 'complex128') self.assert_(h.dtype['Info']['y2'].name == 'float64') self.assert_(h.dtype['info']['Name'].name == 'unicode256') @@ -313,7 +312,7 @@ def test_nested2_descriptor(self): """Check access nested descriptors of a nested array (2nd level)""" - h = array(self._buffer, dtype=self._descr) + h = np.array(self._buffer, dtype=self._descr) self.assert_(h.dtype['Info']['Info2']['value'].name == 'void256') self.assert_(h.dtype['Info']['Info2']['z3'].name == 'void64') @@ -332,26 +331,26 @@ class TestEmptyField(TestCase): def test_assign(self): - a = numpy.arange(10, dtype=numpy.float32) + a = np.arange(10, dtype=np.float32) a.dtype = [("int", "<0i4"),("float", "<2f4")] assert(a['int'].shape == (5,0)) assert(a['float'].shape == (5,2)) class TestCommonType(TestCase): def test_scalar_loses1(self): - res = numpy.find_common_type(['f4','f4','i4'],['f8']) + res = np.find_common_type(['f4','f4','i4'],['f8']) assert(res == 'f4') def test_scalar_loses2(self): - res = numpy.find_common_type(['f4','f4'],['i8']) + res = np.find_common_type(['f4','f4'],['i8']) assert(res == 'f4') def test_scalar_wins(self): - res = numpy.find_common_type(['f4','f4','i4'],['c8']) + res = np.find_common_type(['f4','f4','i4'],['c8']) assert(res == 'c8') def test_scalar_wins2(self): - res = numpy.find_common_type(['u4','i4','i4'],['f4']) + res = np.find_common_type(['u4','i4','i4'],['f4']) assert(res == 'f8') def test_scalar_wins3(self): # doesn't go up to 'f16' on purpose - res = numpy.find_common_type(['u8','i8','i8'],['f8']) + res = np.find_common_type(['u8','i8','i8'],['f8']) assert(res == 'f8') Modified: trunk/numpy/core/tests/test_records.py =================================================================== --- trunk/numpy/core/tests/test_records.py 2008-07-03 02:34:59 UTC (rev 5334) +++ trunk/numpy/core/tests/test_records.py 2008-07-03 02:49:02 UTC (rev 5335) @@ -1,8 +1,6 @@ +from os import path import numpy as np from numpy.testing import * -from os import path -set_package_path() -restore_path() class TestFromrecords(TestCase): def test_fromrecords(self): Modified: trunk/numpy/core/tests/test_regression.py =================================================================== --- trunk/numpy/core/tests/test_regression.py 2008-07-03 02:34:59 UTC (rev 5334) +++ trunk/numpy/core/tests/test_regression.py 2008-07-03 02:49:02 UTC (rev 5335) @@ -3,9 +3,7 @@ import sys from os import path from numpy.testing import * -set_local_path() import numpy as np -restore_path() rlevel = 1 Modified: trunk/numpy/core/tests/test_scalarmath.py =================================================================== --- trunk/numpy/core/tests/test_scalarmath.py 2008-07-03 02:34:59 UTC (rev 5334) +++ trunk/numpy/core/tests/test_scalarmath.py 2008-07-03 02:49:02 UTC (rev 5335) @@ -1,6 +1,5 @@ from numpy.testing import * import numpy.core.umath as ncu -from numpy import array import numpy as np types = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc, np.uintc, @@ -20,10 +19,10 @@ # list of types for k, atype in enumerate(types): vala = atype(3) - val1 = array([3],dtype=atype) + val1 = np.array([3],dtype=atype) for l, btype in enumerate(types): valb = btype(1) - val2 = array([1],dtype=btype) + val2 = np.array([1],dtype=btype) val = vala+valb valo = val1 + val2 assert val.dtype.num == valo.dtype.num and \ @@ -32,7 +31,7 @@ def test_type_create(self, level=1): for k, atype in enumerate(types): - a = array([1,2,3],atype) + a = np.array([1,2,3],atype) b = atype([1,2,3]) assert_equal(a,b) @@ -67,8 +66,8 @@ assert_equal(map(int,a), li[:3]) -#class TestRepr(NumpyTestCase): -# def check_repr(self): +#class TestRepr(TestCase): +# def test_repr(self): # for t in types: # val = t(1197346475.0137341) # val_repr = repr(val) @@ -89,7 +88,7 @@ # could add some more types to the list below for which in ['small denorm','small norm']: # Values from http://en.wikipedia.org/wiki/IEEE_754 - constr = array([0x00]*storage_bytes,dtype=np.uint8) + constr = np.array([0x00]*storage_bytes,dtype=np.uint8) if which == 'small denorm': byte = last_fraction_bit_idx // 8 bytebit = 7-(last_fraction_bit_idx % 8) Modified: trunk/numpy/core/tests/test_umath.py =================================================================== --- trunk/numpy/core/tests/test_umath.py 2008-07-03 02:34:59 UTC (rev 5334) +++ trunk/numpy/core/tests/test_umath.py 2008-07-03 02:49:02 UTC (rev 5335) @@ -1,22 +1,18 @@ from numpy.testing import * -set_package_path() -from numpy.core.umath import minimum, maximum, exp import numpy.core.umath as ncu -from numpy import zeros, ndarray, array, choose, pi import numpy as np -restore_path() class TestDivision(TestCase): def test_division_int(self): # int division should return the floor of the result, a la Python - x = array([5, 10, 90, 100, -5, -10, -90, -100, -120]) + x = np.array([5, 10, 90, 100, -5, -10, -90, -100, -120]) assert_equal(x / 100, [0, 0, 0, 1, -1, -1, -1, -1, -2]) assert_equal(x // 100, [0, 0, 0, 1, -1, -1, -1, -1, -2]) assert_equal(x % 100, [5, 10, 90, 0, 95, 90, 10, 0, 80]) class TestPower(TestCase): def test_power_float(self): - x = array([1., 2., 3.]) + x = np.array([1., 2., 3.]) assert_equal(x**0, [1., 1., 1.]) assert_equal(x**1, x) assert_equal(x**2, [1., 4., 9.]) @@ -27,7 +23,7 @@ assert_almost_equal(x**(0.5), [1., ncu.sqrt(2), ncu.sqrt(3)]) def test_power_complex(self): - x = array([1+2j, 2+3j, 3+4j]) + x = np.array([1+2j, 2+3j, 3+4j]) assert_equal(x**0, [1., 1., 1.]) assert_equal(x**1, x) assert_equal(x**2, [-3+4j, -5+12j, -7+24j]) @@ -52,12 +48,12 @@ class TestMaximum(TestCase): def test_reduce_complex(self): - assert_equal(maximum.reduce([1,2j]),1) - assert_equal(maximum.reduce([1+3j,2j]),1+3j) + assert_equal(ncu.maximum.reduce([1,2j]),1) + assert_equal(ncu.maximum.reduce([1+3j,2j]),1+3j) class TestMinimum(TestCase): def test_reduce_complex(self): - assert_equal(minimum.reduce([1,2j]),2j) + assert_equal(ncu.minimum.reduce([1,2j]),2j) class TestFloatingPoint(TestCase): def test_floating_point(self): @@ -65,29 +61,29 @@ class TestDegrees(TestCase): def test_degrees(self): - assert_almost_equal(ncu.degrees(pi), 180.0) - assert_almost_equal(ncu.degrees(-0.5*pi), -90.0) + assert_almost_equal(ncu.degrees(np.pi), 180.0) + assert_almost_equal(ncu.degrees(-0.5*np.pi), -90.0) class TestRadians(TestCase): def test_radians(self): - assert_almost_equal(ncu.radians(180.0), pi) - assert_almost_equal(ncu.radians(-90.0), -0.5*pi) + assert_almost_equal(ncu.radians(180.0), np.pi) + assert_almost_equal(ncu.radians(-90.0), -0.5*np.pi) class TestSpecialMethods(TestCase): def test_wrap(self): class with_wrap(object): def __array__(self): - return zeros(1) + return np.zeros(1) def __array_wrap__(self, arr, context): r = with_wrap() r.arr = arr r.context = context return r a = with_wrap() - x = minimum(a, a) - assert_equal(x.arr, zeros(1)) + x = ncu.minimum(a, a) + assert_equal(x.arr, np.zeros(1)) func, args, i = x.context - self.failUnless(func is minimum) + self.failUnless(func is ncu.minimum) self.failUnlessEqual(len(args), 2) assert_equal(args[0], a) assert_equal(args[1], a) @@ -96,19 +92,19 @@ def test_old_wrap(self): class with_wrap(object): def __array__(self): - return zeros(1) + return np.zeros(1) def __array_wrap__(self, arr): r = with_wrap() r.arr = arr return r a = with_wrap() - x = minimum(a, a) - assert_equal(x.arr, zeros(1)) + x = ncu.minimum(a, a) + assert_equal(x.arr, np.zeros(1)) def test_priority(self): class A(object): def __array__(self): - return zeros(1) + return np.zeros(1) def __array_wrap__(self, arr, context): r = type(self)() r.arr = arr @@ -118,12 +114,12 @@ __array_priority__ = 20. class C(A): __array_priority__ = 40. - x = zeros(1) + x = np.zeros(1) a = A() b = B() c = C() - f = minimum - self.failUnless(type(f(x,x)) is ndarray) + f = ncu.minimum + self.failUnless(type(f(x,x)) is np.ndarray) self.failUnless(type(f(x,a)) is A) self.failUnless(type(f(x,b)) is B) self.failUnless(type(f(x,c)) is C) @@ -139,18 +135,18 @@ self.failUnless(type(f(c,b)) is C) self.failUnless(type(f(c,c)) is C) - self.failUnless(type(exp(a) is A)) - self.failUnless(type(exp(b) is B)) - self.failUnless(type(exp(c) is C)) + self.failUnless(type(ncu.exp(a) is A)) + self.failUnless(type(ncu.exp(b) is B)) + self.failUnless(type(ncu.exp(c) is C)) def test_failing_wrap(self): class A(object): def __array__(self): - return zeros(1) + return np.zeros(1) def __array_wrap__(self, arr, context): raise RuntimeError a = A() - self.failUnlessRaises(RuntimeError, maximum, a, a) + self.failUnlessRaises(RuntimeError, ncu.maximum, a, a) def test_array_with_context(self): class A(object): @@ -159,28 +155,28 @@ self.func = func self.args = args self.i = i - return zeros(1) + return np.zeros(1) class B(object): def __array__(self, dtype=None): - return zeros(1, dtype) + return np.zeros(1, dtype) class C(object): def __array__(self): - return zeros(1) + return np.zeros(1) a = A() - maximum(zeros(1), a) - self.failUnless(a.func is maximum) + ncu.maximum(np.zeros(1), a) + self.failUnless(a.func is ncu.maximum) assert_equal(a.args[0], 0) self.failUnless(a.args[1] is a) self.failUnless(a.i == 1) - assert_equal(maximum(a, B()), 0) - assert_equal(maximum(a, C()), 0) + assert_equal(ncu.maximum(a, B()), 0) + assert_equal(ncu.maximum(a, C()), 0) class TestChoose(TestCase): def test_mixed(self): - c = array([True,True]) - a = array([True,True]) - assert_equal(choose(c, (a, 1)), array([1,1])) + c = np.array([True,True]) + a = np.array([True,True]) + assert_equal(np.choose(c, (a, 1)), np.array([1,1])) class TestComplexFunctions(TestCase): Modified: trunk/numpy/core/tests/test_unicode.py =================================================================== --- trunk/numpy/core/tests/test_unicode.py 2008-07-03 02:34:59 UTC (rev 5334) +++ trunk/numpy/core/tests/test_unicode.py 2008-07-03 02:49:02 UTC (rev 5335) @@ -1,4 +1,3 @@ -import sys from numpy.testing import * from numpy.core import * From numpy-svn at scipy.org Wed Jul 2 23:35:52 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 2 Jul 2008 22:35:52 -0500 (CDT) Subject: [Numpy-svn] r5336 - trunk/numpy/testing Message-ID: <20080703033552.00A8D39C4B4@scipy.org> Author: alan.mcintyre Date: 2008-07-02 22:35:50 -0500 (Wed, 02 Jul 2008) New Revision: 5336 Modified: trunk/numpy/testing/decorators.py trunk/numpy/testing/nosetester.py Log: Fixed line continuation in doctest for setastest. Remove unnecessary "import re". Limit doctest execution environment to "import numpy as np". Save and restore print options after each doctest (to clean up after some doctests that change them). Enable ellipsis for all doctests. Remove parameter to NumpyDocTestCase constructor that was specific to nose 0.11. Monkeypatch wantFile of doctest plugin to skip Python files related to the build process (scons_support.py and generate_numpy_api.py). Modified: trunk/numpy/testing/decorators.py =================================================================== --- trunk/numpy/testing/decorators.py 2008-07-03 02:49:02 UTC (rev 5335) +++ trunk/numpy/testing/decorators.py 2008-07-03 03:35:50 UTC (rev 5336) @@ -31,7 +31,7 @@ e.g >>> @setastest(False) - >>> def func_with_test_in_name(arg1, arg2): pass + ... def func_with_test_in_name(arg1, arg2): pass ... >>> Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-03 02:49:02 UTC (rev 5335) +++ trunk/numpy/testing/nosetester.py 2008-07-03 03:35:50 UTC (rev 5336) @@ -5,10 +5,8 @@ ''' import os import sys -import re import warnings - # Patches nose functionality to add NumPy-specific features # Note: This class should only be instantiated if nose has already # been successfully imported @@ -20,8 +18,17 @@ return NoseCustomizer.__patched = True + + # used to monkeypatch the nose doctest classes + def monkeypatch_method(cls): + def decorator(func): + setattr(cls, func.__name__, func) + return func + return decorator + from nose.plugins import doctests as npd - from nose.util import src + from nose.plugins.base import Plugin + from nose.util import src, tolist import numpy import doctest @@ -53,11 +60,13 @@ checker=checker) + # This will replace the existing loadTestsFromModule method of # nose.plugins.doctests.Doctest. It turns on whitespace normalization, # adds an implicit "import numpy as np" for doctests, and adds a # "#random" directive to allow executing a command while ignoring its # output. + @monkeypatch_method(npd.Doctest) def loadTestsFromModule(self, module): if not self.matches(module.__name__): npd.log.debug("Doctest doesn't want module %s", module) @@ -78,19 +87,41 @@ if not test.filename: test.filename = module_file - # implicit "import numpy as np" for all doctests - test.globs['np'] = numpy + # Each doctest should execute in an environment equivalent to + # starting Python and executing "import numpy as np" + test.globs = {'__builtins__':__builtins__, + 'np':numpy} - optionflags = doctest.NORMALIZE_WHITESPACE + # always use whitespace and ellipsis options + optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS + yield NumpyDocTestCase(test, optionflags=optionflags, - result_var=self.doctest_result_var, checker=NumpyDoctestOutputChecker()) - # Monkeypatch loadTestsFromModule - npd.Doctest.loadTestsFromModule = loadTestsFromModule + # get original print options + print_state = numpy.get_printoptions() + # Add an afterContext method to nose.plugins.doctests.Doctest in order + # to restore print options to the original state after each doctest + @monkeypatch_method(npd.Doctest) + def afterContext(self): + numpy.set_printoptions(**print_state) + # Replace the existing wantFile method of nose.plugins.doctests.Doctest + # so that we can ignore NumPy-specific build files that shouldn't + # be searched for tests + old_wantFile = npd.Doctest.wantFile + ignore_files = ['generate_numpy_api.py', 'scons_support.py'] + def wantFile(self, file): + bn = os.path.basename(file) + if bn in ignore_files: + return False + return old_wantFile(self, file) + + npd.Doctest.wantFile = wantFile + + def import_nose(): """ Import nose only when needed. """ From numpy-svn at scipy.org Wed Jul 2 23:51:50 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 2 Jul 2008 22:51:50 -0500 (CDT) Subject: [Numpy-svn] r5337 - trunk/numpy/lib Message-ID: <20080703035150.D18A239C10E@scipy.org> Author: alan.mcintyre Date: 2008-07-02 22:51:46 -0500 (Wed, 02 Jul 2008) New Revision: 5337 Modified: trunk/numpy/lib/function_base.py trunk/numpy/lib/polynomial.py trunk/numpy/lib/scimath.py trunk/numpy/lib/shape_base.py trunk/numpy/lib/utils.py Log: Use the implicit "import numpy as np" made available to all doctests instead of an explicit import. Remove ">>>" from bartlett plotting example since it currently requires matplotlib. Modified: trunk/numpy/lib/function_base.py =================================================================== --- trunk/numpy/lib/function_base.py 2008-07-03 03:35:50 UTC (rev 5336) +++ trunk/numpy/lib/function_base.py 2008-07-03 03:51:46 UTC (rev 5337) @@ -319,8 +319,8 @@ Examples -------- - >>> x = random.randn(100,3) - >>> hist3d, edges = histogramdd(x, bins = (5, 6, 7)) + >>> x = np.random.randn(100,3) + >>> hist3d, edges = np.lib.histogramdd(x, bins = (5, 6, 7)) """ @@ -833,9 +833,9 @@ Examples -------- - >>> numpy.angle(1+1j) # in radians + >>> np.angle(1+1j) # in radians 0.78539816339744828 - >>> numpy.angle(1+1j,deg=True) # in degrees + >>> np.angle(1+1j,deg=True) # in degrees 45.0 """ @@ -893,9 +893,8 @@ Examples -------- - >>> import numpy >>> a = array((0, 0, 0, 1, 2, 3, 2, 1, 0)) - >>> numpy.trim_zeros(a) + >>> np.trim_zeros(a) array([1, 2, 3, 2, 1]) """ @@ -922,7 +921,7 @@ Examples -------- - >>> numpy.unique([5,2,4,0,4,4,2,2,1]) + >>> np.unique([5,2,4,0,4,4,2,2,1]) array([0, 1, 2, 4, 5]) """ @@ -1270,35 +1269,33 @@ Examples -------- - >>> from numpy import bartlett - >>> bartlett(12) + >>> np.bartlett(12) array([ 0. , 0.18181818, 0.36363636, 0.54545455, 0.72727273, 0.90909091, 0.90909091, 0.72727273, 0.54545455, 0.36363636, 0.18181818, 0. ]) - Plot the window and its frequency response: + Plot the window and its frequency response (requires SciPy and matplotlib): - >>> from numpy import clip, log10, array, bartlett - >>> from scipy.fftpack import fft - >>> from matplotlib import pyplot as plt + from scipy.fftpack import fft + from matplotlib import pyplot as plt - >>> window = bartlett(51) - >>> plt.plot(window) - >>> plt.title("Bartlett window") - >>> plt.ylabel("Amplitude") - >>> plt.xlabel("Sample") - >>> plt.show() + window = np.bartlett(51) + plt.plot(window) #doctest: SKIP + plt.title("Bartlett window") + plt.ylabel("Amplitude") + plt.xlabel("Sample") + plt.show() - >>> A = fft(window, 2048) / 25.5 - >>> mag = abs(fftshift(A)) - >>> freq = linspace(-0.5,0.5,len(A)) - >>> response = 20*log10(mag) - >>> response = clip(response,-100,100) - >>> plt.plot(freq, response) - >>> plt.title("Frequency response of Bartlett window") - >>> plt.ylabel("Magnitude [dB]") - >>> plt.xlabel("Normalized frequency [cycles per sample]") - >>> plt.axis('tight'); plt.show() + A = fft(window, 2048) / 25.5 + mag = abs(np.fft.fftshift(A)) + freq = linspace(-0.5,0.5,len(A)) + response = 20*np.log10(mag) + response = np.clip(response,-100,100) + plt.plot(freq, response) + plt.title("Frequency response of Bartlett window") + plt.ylabel("Magnitude [dB]") + plt.xlabel("Normalized frequency [cycles per sample]") + plt.axis('tight'); plt.show() """ if M < 1: @@ -1489,7 +1486,6 @@ Examples -------- - >>> import numpy as np >>> from numpy import median >>> a = np.array([[10, 7, 4], [3, 2, 1]]) >>> a Modified: trunk/numpy/lib/polynomial.py =================================================================== --- trunk/numpy/lib/polynomial.py 2008-07-03 03:35:50 UTC (rev 5336) +++ trunk/numpy/lib/polynomial.py 2008-07-03 03:51:46 UTC (rev 5337) @@ -223,7 +223,6 @@ ----- RankWarning : if rank is reduced and not full output The warnings can be turned off by: - >>> import numpy as np >>> import warnings >>> warnings.simplefilter('ignore',np.RankWarning) Modified: trunk/numpy/lib/scimath.py =================================================================== --- trunk/numpy/lib/scimath.py 2008-07-03 03:35:50 UTC (rev 5336) +++ trunk/numpy/lib/scimath.py 2008-07-03 03:51:46 UTC (rev 5337) @@ -46,8 +46,6 @@ Examples -------- - >>> import numpy as np - First, consider an input of type short: >>> a = np.array([1,2,3],np.short) @@ -246,7 +244,7 @@ -------- (We set the printing precision so the example can be auto-tested) - >>> import numpy as np; np.set_printoptions(precision=4) + >>> np.set_printoptions(precision=4) >>> log10([10**1,10**2]) array([ 1., 2.]) @@ -276,7 +274,7 @@ -------- (We set the printing precision so the example can be auto-tested) - >>> import numpy as np; np.set_printoptions(precision=4) + >>> np.set_printoptions(precision=4) >>> logn(2,[4,8]) array([ 2., 3.]) @@ -306,7 +304,7 @@ -------- (We set the printing precision so the example can be auto-tested) - >>> import numpy as np; np.set_printoptions(precision=4) + >>> np.set_printoptions(precision=4) >>> log2([4,8]) array([ 2., 3.]) @@ -336,7 +334,7 @@ Examples -------- (We set the printing precision so the example can be auto-tested) - >>> import numpy as np; np.set_printoptions(precision=4) + >>> np.set_printoptions(precision=4) >>> power([2,4],2) array([ 4, 16]) @@ -368,7 +366,7 @@ Examples -------- - >>> import numpy as np; np.set_printoptions(precision=4) + >>> np.set_printoptions(precision=4) >>> arccos(1) 0.0 @@ -397,7 +395,7 @@ Examples -------- (We set the printing precision so the example can be auto-tested) - >>> import numpy as np; np.set_printoptions(precision=4) + >>> np.set_printoptions(precision=4) >>> arcsin(0) 0.0 @@ -426,7 +424,7 @@ Examples -------- (We set the printing precision so the example can be auto-tested) - >>> import numpy as np; np.set_printoptions(precision=4) + >>> np.set_printoptions(precision=4) >>> arctanh(0) 0.0 Modified: trunk/numpy/lib/shape_base.py =================================================================== --- trunk/numpy/lib/shape_base.py 2008-07-03 03:35:50 UTC (rev 5336) +++ trunk/numpy/lib/shape_base.py 2008-07-03 03:51:46 UTC (rev 5337) @@ -192,15 +192,14 @@ tup -- sequence of arrays. All arrays must have the same shape. Examples: - >>> import numpy >>> a = array((1,2,3)) >>> b = array((2,3,4)) - >>> numpy.vstack((a,b)) + >>> np.vstack((a,b)) array([[1, 2, 3], [2, 3, 4]]) >>> a = array([[1],[2],[3]]) >>> b = array([[2],[3],[4]]) - >>> numpy.vstack((a,b)) + >>> np.vstack((a,b)) array([[1], [2], [3], Modified: trunk/numpy/lib/utils.py =================================================================== --- trunk/numpy/lib/utils.py 2008-07-03 03:35:50 UTC (rev 5336) +++ trunk/numpy/lib/utils.py 2008-07-03 03:51:46 UTC (rev 5337) @@ -316,8 +316,7 @@ """Get help information for a function, class, or module. Example: - >>> from numpy import * - >>> info(polyval) # doctest: +SKIP + >>> np.info(np.polyval) # doctest: +SKIP polyval(p, x) From numpy-svn at scipy.org Wed Jul 2 23:57:36 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 2 Jul 2008 22:57:36 -0500 (CDT) Subject: [Numpy-svn] r5338 - trunk/numpy/lib/tests Message-ID: <20080703035736.502B139C10E@scipy.org> Author: alan.mcintyre Date: 2008-07-02 22:57:29 -0500 (Wed, 02 Jul 2008) New Revision: 5338 Modified: trunk/numpy/lib/tests/test_arraysetops.py trunk/numpy/lib/tests/test_financial.py trunk/numpy/lib/tests/test_format.py trunk/numpy/lib/tests/test_function_base.py trunk/numpy/lib/tests/test_index_tricks.py trunk/numpy/lib/tests/test_regression.py trunk/numpy/lib/tests/test_shape_base.py trunk/numpy/lib/tests/test_twodim_base.py trunk/numpy/lib/tests/test_type_check.py Log: Remove uses of set_package_path, set_local_path, restore_path. Clean up and (somewhat) standardize test module imports. Removed unneeded reload calls. Modified: trunk/numpy/lib/tests/test_arraysetops.py =================================================================== --- trunk/numpy/lib/tests/test_arraysetops.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_arraysetops.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -3,83 +3,67 @@ """ from numpy.testing import * -set_package_path() -import numpy +import numpy as np from numpy.lib.arraysetops import * -restore_path() -################################################## - class TestAso(TestCase): - ## - # 03.11.2005, c def test_unique1d( self ): + a = np.array( [5, 7, 1, 2, 1, 5, 7] ) - a = numpy.array( [5, 7, 1, 2, 1, 5, 7] ) - - ec = numpy.array( [1, 2, 5, 7] ) + ec = np.array( [1, 2, 5, 7] ) c = unique1d( a ) assert_array_equal( c, ec ) assert_array_equal([], unique1d([])) - ## - # 03.11.2005, c def test_intersect1d( self ): + a = np.array( [5, 7, 1, 2] ) + b = np.array( [2, 4, 3, 1, 5] ) - a = numpy.array( [5, 7, 1, 2] ) - b = numpy.array( [2, 4, 3, 1, 5] ) - - ec = numpy.array( [1, 2, 5] ) + ec = np.array( [1, 2, 5] ) c = intersect1d( a, b ) assert_array_equal( c, ec ) assert_array_equal([], intersect1d([],[])) - ## - # 03.11.2005, c def test_intersect1d_nu( self ): + a = np.array( [5, 5, 7, 1, 2] ) + b = np.array( [2, 1, 4, 3, 3, 1, 5] ) - a = numpy.array( [5, 5, 7, 1, 2] ) - b = numpy.array( [2, 1, 4, 3, 3, 1, 5] ) - - ec = numpy.array( [1, 2, 5] ) + ec = np.array( [1, 2, 5] ) c = intersect1d_nu( a, b ) assert_array_equal( c, ec ) assert_array_equal([], intersect1d_nu([],[])) - ## - # 03.11.2005, c def test_setxor1d( self ): + a = np.array( [5, 7, 1, 2] ) + b = np.array( [2, 4, 3, 1, 5] ) - a = numpy.array( [5, 7, 1, 2] ) - b = numpy.array( [2, 4, 3, 1, 5] ) - - ec = numpy.array( [3, 4, 7] ) + ec = np.array( [3, 4, 7] ) c = setxor1d( a, b ) assert_array_equal( c, ec ) - a = numpy.array( [1, 2, 3] ) - b = numpy.array( [6, 5, 4] ) + a = np.array( [1, 2, 3] ) + b = np.array( [6, 5, 4] ) - ec = numpy.array( [1, 2, 3, 4, 5, 6] ) + ec = np.array( [1, 2, 3, 4, 5, 6] ) c = setxor1d( a, b ) assert_array_equal( c, ec ) - a = numpy.array( [1, 8, 2, 3] ) - b = numpy.array( [6, 5, 4, 8] ) + a = np.array( [1, 8, 2, 3] ) + b = np.array( [6, 5, 4, 8] ) - ec = numpy.array( [1, 2, 3, 4, 5, 6] ) + ec = np.array( [1, 2, 3, 4, 5, 6] ) c = setxor1d( a, b ) assert_array_equal( c, ec ) assert_array_equal([], setxor1d([],[])) def test_ediff1d(self): - zero_elem = numpy.array([]) - one_elem = numpy.array([1]) - two_elem = numpy.array([1,2]) + zero_elem = np.array([]) + one_elem = np.array([1]) + two_elem = np.array([1,2]) assert_array_equal([],ediff1d(zero_elem)) assert_array_equal([0],ediff1d(zero_elem,to_begin=0)) @@ -88,81 +72,68 @@ assert_array_equal([],ediff1d(one_elem)) assert_array_equal([1],ediff1d(two_elem)) - ## - # 03.11.2005, c def test_setmember1d( self ): + a = np.array( [5, 7, 1, 2] ) + b = np.array( [2, 4, 3, 1, 5] ) - a = numpy.array( [5, 7, 1, 2] ) - b = numpy.array( [2, 4, 3, 1, 5] ) - - ec = numpy.array( [True, False, True, True] ) + ec = np.array( [True, False, True, True] ) c = setmember1d( a, b ) assert_array_equal( c, ec ) a[0] = 8 - ec = numpy.array( [False, False, True, True] ) + ec = np.array( [False, False, True, True] ) c = setmember1d( a, b ) assert_array_equal( c, ec ) a[0], a[3] = 4, 8 - ec = numpy.array( [True, False, True, False] ) + ec = np.array( [True, False, True, False] ) c = setmember1d( a, b ) assert_array_equal( c, ec ) assert_array_equal([], setmember1d([],[])) - ## - # 03.11.2005, c def test_union1d( self ): + a = np.array( [5, 4, 7, 1, 2] ) + b = np.array( [2, 4, 3, 3, 2, 1, 5] ) - a = numpy.array( [5, 4, 7, 1, 2] ) - b = numpy.array( [2, 4, 3, 3, 2, 1, 5] ) - - ec = numpy.array( [1, 2, 3, 4, 5, 7] ) + ec = np.array( [1, 2, 3, 4, 5, 7] ) c = union1d( a, b ) assert_array_equal( c, ec ) assert_array_equal([], union1d([],[])) - ## - # 03.11.2005, c - # 09.01.2006 def test_setdiff1d( self ): + a = np.array( [6, 5, 4, 7, 1, 2] ) + b = np.array( [2, 4, 3, 3, 2, 1, 5] ) - a = numpy.array( [6, 5, 4, 7, 1, 2] ) - b = numpy.array( [2, 4, 3, 3, 2, 1, 5] ) - - ec = numpy.array( [6, 7] ) + ec = np.array( [6, 7] ) c = setdiff1d( a, b ) assert_array_equal( c, ec ) - a = numpy.arange( 21 ) - b = numpy.arange( 19 ) - ec = numpy.array( [19, 20] ) + a = np.arange( 21 ) + b = np.arange( 19 ) + ec = np.array( [19, 20] ) c = setdiff1d( a, b ) assert_array_equal( c, ec ) assert_array_equal([], setdiff1d([],[])) def test_setdiff1d_char_array(self): - a = numpy.array(['a','b','c']) - b = numpy.array(['a','b','s']) - assert_array_equal(setdiff1d(a,b),numpy.array(['c'])) + a = np.array(['a','b','c']) + b = np.array(['a','b','s']) + assert_array_equal(setdiff1d(a,b),np.array(['c'])) - ## - # 03.11.2005, c def test_manyways( self ): - nItem = 100 - a = numpy.fix( nItem / 10 * numpy.random.random( nItem ) ) - b = numpy.fix( nItem / 10 * numpy.random.random( nItem ) ) + a = np.fix( nItem / 10 * np.random.random( nItem ) ) + b = np.fix( nItem / 10 * np.random.random( nItem ) ) c1 = intersect1d_nu( a, b ) c2 = unique1d( intersect1d( a, b ) ) assert_array_equal( c1, c2 ) - a = numpy.array( [5, 7, 1, 2, 8] ) - b = numpy.array( [9, 8, 2, 4, 3, 1, 5] ) + a = np.array( [5, 7, 1, 2, 8] ) + b = np.array( [9, 8, 2, 4, 3, 1, 5] ) c1 = setxor1d( a, b ) aux1 = intersect1d( a, b ) Modified: trunk/numpy/lib/tests/test_financial.py =================================================================== --- trunk/numpy/lib/tests/test_financial.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_financial.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -1,31 +1,29 @@ """ ->>> from numpy import rate, irr, pv, fv, pmt, nper, npv, mirr, round - ->>> round(rate(10,0,-3500,10000),4)==0.1107 +>>> np.round(np.rate(10,0,-3500,10000),4)==0.1107 True ->>> round(irr([-150000, 15000, 25000, 35000, 45000, 60000]),4)==0.0524 +>>> np.round(np.irr([-150000, 15000, 25000, 35000, 45000, 60000]),4)==0.0524 True ->>> round(pv(0.07,20,12000,0),2) == -127128.17 +>>> np.round(np.pv(0.07,20,12000,0),2) == -127128.17 True ->>> round(fv(0.075, 20, -2000,0,0),2) == 86609.36 +>>> np.round(np.fv(0.075, 20, -2000,0,0),2) == 86609.36 True ->>> round(pmt(0.08/12,5*12,15000),3) == -304.146 +>>> np.round(np.pmt(0.08/12,5*12,15000),3) == -304.146 True ->>> round(nper(0.075,-2000,0,100000.),2) == 21.54 +>>> np.round(np.nper(0.075,-2000,0,100000.),2) == 21.54 True ->>> round(npv(0.05,[-15000,1500,2500,3500,4500,6000]),2) == 117.04 +>>> np.round(np.npv(0.05,[-15000,1500,2500,3500,4500,6000]),2) == 117.04 True ->>> round(mirr([-4500,-800,800,800,600,600,800,800,700,3000],0.08,0.055),4) == 0.0665 +>>> np.round(np.mirr([-4500,-800,800,800,600,600,800,800,700,3000],0.08,0.055),4) == 0.0665 True ->>> round(mirr([-120000,39000,30000,21000,37000,46000],0.10,0.12),4)==0.1344 +>>> np.round(np.mirr([-120000,39000,30000,21000,37000,46000],0.10,0.12),4)==0.1344 True """ Modified: trunk/numpy/lib/tests/test_format.py =================================================================== --- trunk/numpy/lib/tests/test_format.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_format.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -2,7 +2,6 @@ Set up: - >>> import numpy as np >>> from cStringIO import StringIO >>> from numpy.lib import format >>> Modified: trunk/numpy/lib/tests/test_function_base.py =================================================================== --- trunk/numpy/lib/tests/test_function_base.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_function_base.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -1,11 +1,9 @@ import sys from numpy.testing import * -set_package_path() -import numpy.lib;reload(numpy.lib) +import numpy.lib from numpy.lib import * from numpy.core import * -restore_path() class TestAny(TestCase): def test_basic(self): Modified: trunk/numpy/lib/tests/test_index_tricks.py =================================================================== --- trunk/numpy/lib/tests/test_index_tricks.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_index_tricks.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -1,7 +1,5 @@ from numpy.testing import * -set_package_path() from numpy import array, ones, r_, mgrid -restore_path() class TestGrid(TestCase): def test_basic(self): Modified: trunk/numpy/lib/tests/test_regression.py =================================================================== --- trunk/numpy/lib/tests/test_regression.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_regression.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -1,8 +1,5 @@ from numpy.testing import * - -set_local_path() import numpy as np -restore_path() rlevel = 1 Modified: trunk/numpy/lib/tests/test_shape_base.py =================================================================== --- trunk/numpy/lib/tests/test_shape_base.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_shape_base.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -1,8 +1,6 @@ from numpy.testing import * -set_package_path() from numpy.lib import * from numpy.core import * -restore_path() class TestApplyAlongAxis(TestCase): def test_simple(self): Modified: trunk/numpy/lib/tests/test_twodim_base.py =================================================================== --- trunk/numpy/lib/tests/test_twodim_base.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_twodim_base.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -3,15 +3,10 @@ """ from numpy.testing import * -set_package_path() from numpy import arange, rot90, add, fliplr, flipud, zeros, ones, eye, \ array, diag, histogram2d, tri import numpy as np -restore_path() -################################################## - - def get_mat(n): data = arange(n) data = add.outer(data,data) Modified: trunk/numpy/lib/tests/test_type_check.py =================================================================== --- trunk/numpy/lib/tests/test_type_check.py 2008-07-03 03:51:46 UTC (rev 5337) +++ trunk/numpy/lib/tests/test_type_check.py 2008-07-03 03:57:29 UTC (rev 5338) @@ -1,11 +1,7 @@ -import sys - from numpy.testing import * -set_package_path() -import numpy.lib;reload(numpy.lib);reload(numpy.lib.type_check) +import numpy.lib from numpy.lib import * from numpy.core import * -restore_path() def assert_all(x): assert(all(x)), x From numpy-svn at scipy.org Thu Jul 3 02:15:17 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 01:15:17 -0500 (CDT) Subject: [Numpy-svn] r5339 - in trunk/numpy: lib lib/tests ma Message-ID: <20080703061517.B9A8D39C5A1@scipy.org> Author: rkern Date: 2008-07-03 01:15:14 -0500 (Thu, 03 Jul 2008) New Revision: 5339 Modified: trunk/numpy/lib/_datasource.py trunk/numpy/lib/getlimits.py trunk/numpy/lib/polynomial.py trunk/numpy/lib/tests/test__datasource.py trunk/numpy/lib/utils.py trunk/numpy/ma/core.py trunk/numpy/ma/extras.py Log: Reduce numpy's import times by delaying a few time consuming imports to the point of actual use and global instantiations of finfo. Thanks to David Cournapeau for tracking down and fixing the import part of the problem. Modified: trunk/numpy/lib/_datasource.py =================================================================== --- trunk/numpy/lib/_datasource.py 2008-07-03 03:57:29 UTC (rev 5338) +++ trunk/numpy/lib/_datasource.py 2008-07-03 06:15:14 UTC (rev 5339) @@ -37,7 +37,6 @@ import os import tempfile from shutil import rmtree -from urllib2 import urlopen, URLError from urlparse import urlparse # TODO: .zip support, .tar support? @@ -196,6 +195,9 @@ Creates a copy of the file in the datasource cache. """ + # We import these here because importing urllib2 is slow and + # a significant fraction of numpy's total import time. + from urllib2 import urlopen, URLError upath = self.abspath(path) @@ -337,6 +339,9 @@ is accessible if it exists in either location. """ + # We import this here because importing urllib2 is slow and + # a significant fraction of numpy's total import time. + from urllib2 import URLError # Test local path if os.path.exists(path): Modified: trunk/numpy/lib/getlimits.py =================================================================== --- trunk/numpy/lib/getlimits.py 2008-07-03 03:57:29 UTC (rev 5338) +++ trunk/numpy/lib/getlimits.py 2008-07-03 06:15:14 UTC (rev 5339) @@ -21,14 +21,16 @@ } class finfo(object): - """Machine limits for floating point types. + """ Machine limits for floating point types. - :Parameters: - dtype : floating point type or instance + Parameters + ---------- + dtype : floating point type, dtype, or instance + The kind of floating point data type to get information about. - :SeeAlso: - - numpy.lib.machar.MachAr - + See Also + -------- + numpy.lib.machar.MachAr """ _finfo_cache = {} Modified: trunk/numpy/lib/polynomial.py =================================================================== --- trunk/numpy/lib/polynomial.py 2008-07-03 03:57:29 UTC (rev 5338) +++ trunk/numpy/lib/polynomial.py 2008-07-03 06:15:14 UTC (rev 5339) @@ -17,8 +17,6 @@ from numpy.lib.function_base import trim_zeros, sort_complex eigvals = None lstsq = None -_single_eps = finfo(NX.single).eps -_double_eps = finfo(NX.double).eps class RankWarning(UserWarning): """Issued by polyfit when Vandermonde matrix is rank deficient. @@ -301,11 +299,7 @@ # set rcond if rcond is None : - xtype = x.dtype - if xtype == NX.single or xtype == NX.csingle : - rcond = len(x)*_single_eps - else : - rcond = len(x)*_double_eps + rcond = len(x)*finfo(x.dtype).eps # scale x to improve condition number scale = abs(x).max() Modified: trunk/numpy/lib/tests/test__datasource.py =================================================================== --- trunk/numpy/lib/tests/test__datasource.py 2008-07-03 03:57:29 UTC (rev 5338) +++ trunk/numpy/lib/tests/test__datasource.py 2008-07-03 06:15:14 UTC (rev 5339) @@ -5,6 +5,7 @@ from tempfile import mkdtemp, mkstemp, NamedTemporaryFile from shutil import rmtree from urlparse import urlparse +from urllib2 import URLError from numpy.testing import * @@ -16,7 +17,7 @@ tmpfile = NamedTemporaryFile(prefix='urltmp_') return tmpfile else: - raise datasource.URLError('Name or service not known') + raise URLError('Name or service not known') # Rebind urlopen during testing. For a 'real' test, uncomment the rebinding # below. Modified: trunk/numpy/lib/utils.py =================================================================== --- trunk/numpy/lib/utils.py 2008-07-03 03:57:29 UTC (rev 5338) +++ trunk/numpy/lib/utils.py 2008-07-03 06:15:14 UTC (rev 5339) @@ -1,11 +1,9 @@ -import compiler import os import sys -import inspect import pkgutil import types import re -import pydoc + from numpy.core.numerictypes import obj2sctype, generic from numpy.core.multiarray import dtype as _dtype from numpy.core import product, ndarray @@ -327,7 +325,8 @@ p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1] """ global _namedict, _dictlist - import pydoc + # Local import to speed up numpy's import time. + import pydoc, inspect if hasattr(object,'_ppimport_importer') or \ hasattr(object, '_ppimport_module'): @@ -467,6 +466,8 @@ def source(object, output=sys.stdout): """Write source for this object to output. """ + # Local import to speed up numpy's import time. + import inspect try: print >> output, "In file: %s\n" % inspect.getsourcefile(object) print >> output, inspect.getsource(object) @@ -599,6 +600,8 @@ """ global _lookfor_caches + # Local import to speed up numpy's import time. + import inspect if module is None: module = "numpy" @@ -751,6 +754,8 @@ ... SyntaxError: Unknown name: dict """ + # Local import to speed up numpy's import time. + import compiler walker = SafeEval() try: ast = compiler.parse(source, "eval") Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-03 03:57:29 UTC (rev 5338) +++ trunk/numpy/ma/core.py 2008-07-03 06:15:14 UTC (rev 5339) @@ -77,7 +77,6 @@ MaskType = np.bool_ nomask = MaskType(0) -divide_tolerance = np.finfo(float).tiny np.seterr(all='ignore') def doc_note(note): @@ -398,9 +397,14 @@ #............................ class _DomainSafeDivide: """Define a domain for safe division.""" - def __init__ (self, tolerance=divide_tolerance): + def __init__ (self, tolerance=None): self.tolerance = tolerance def __call__ (self, a, b): + # Delay the selection of the tolerance to here in order to reduce numpy + # import times. The calculation of these parameters is a substantial + # component of numpy's import time. + if self.tolerance is None: + self.tolerance = np.finfo(float).tiny return umath.absolute(a) * self.tolerance >= umath.absolute(b) #............................ class _DomainGreater: Modified: trunk/numpy/ma/extras.py =================================================================== --- trunk/numpy/ma/extras.py 2008-07-03 03:57:29 UTC (rev 5338) +++ trunk/numpy/ma/extras.py 2008-07-03 06:15:14 UTC (rev 5339) @@ -39,7 +39,7 @@ from numpy import ndarray, array as nxarray import numpy.core.umath as umath from numpy.lib.index_tricks import AxisConcatenator -from numpy.lib.polynomial import _lstsq, _single_eps, _double_eps +from numpy.lib.polynomial import _lstsq #............................................................................... def issequence(seq): @@ -866,10 +866,7 @@ x[m] = y[m] = masked # Set rcond if rcond is None : - if x.dtype in (np.single, np.csingle): - rcond = len(x)*_single_eps - else : - rcond = len(x)*_double_eps + rcond = len(x)*np.finfo(x.dtype).eps # Scale x to improve condition number scale = abs(x).max() if scale != 0 : From numpy-svn at scipy.org Thu Jul 3 02:23:16 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 01:23:16 -0500 (CDT) Subject: [Numpy-svn] r5340 - trunk/numpy/lib Message-ID: <20080703062316.2312539C59C@scipy.org> Author: rkern Date: 2008-07-03 01:23:15 -0500 (Thu, 03 Jul 2008) New Revision: 5340 Modified: trunk/numpy/lib/getlimits.py Log: Added note to numpy developers about the policy on using finfo in numpy's codebase. Modified: trunk/numpy/lib/getlimits.py =================================================================== --- trunk/numpy/lib/getlimits.py 2008-07-03 06:15:14 UTC (rev 5339) +++ trunk/numpy/lib/getlimits.py 2008-07-03 06:23:15 UTC (rev 5340) @@ -31,6 +31,13 @@ See Also -------- numpy.lib.machar.MachAr + + Notes + ----- + For developers of numpy: do not instantiate this at the module level. The + initial calculation of these parameters is expensive and negatively impacts + import times. These objects are cached, so calling `finfo()` repeatedly + inside your functions is not a problem. """ _finfo_cache = {} From numpy-svn at scipy.org Thu Jul 3 02:42:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 01:42:30 -0500 (CDT) Subject: [Numpy-svn] r5341 - in trunk/numpy/lib: . tests Message-ID: <20080703064230.0359B39C3D3@scipy.org> Author: rkern Date: 2008-07-03 01:42:28 -0500 (Thu, 03 Jul 2008) New Revision: 5341 Added: trunk/numpy/lib/stride_tricks.py trunk/numpy/lib/tests/test_stride_tricks.py Modified: trunk/numpy/lib/__init__.py Log: ENH: Add broadcast_arrays() function to expose broadcasting to pure Python functions that cannot be made to be ufuncs. Modified: trunk/numpy/lib/__init__.py =================================================================== --- trunk/numpy/lib/__init__.py 2008-07-03 06:23:15 UTC (rev 5340) +++ trunk/numpy/lib/__init__.py 2008-07-03 06:42:28 UTC (rev 5341) @@ -5,6 +5,7 @@ from index_tricks import * from function_base import * from shape_base import * +from stride_tricks import * from twodim_base import * from ufunclike import * @@ -24,6 +25,7 @@ __all__ += index_tricks.__all__ __all__ += function_base.__all__ __all__ += shape_base.__all__ +__all__ += stride_tricks.__all__ __all__ += twodim_base.__all__ __all__ += ufunclike.__all__ __all__ += polynomial.__all__ Added: trunk/numpy/lib/stride_tricks.py =================================================================== --- trunk/numpy/lib/stride_tricks.py 2008-07-03 06:23:15 UTC (rev 5340) +++ trunk/numpy/lib/stride_tricks.py 2008-07-03 06:42:28 UTC (rev 5341) @@ -0,0 +1,109 @@ +""" Utilities that manipulate strides to achieve desirable effects. +""" +import numpy as np + +__all__ = ['broadcast_arrays'] + +class DummyArray(object): + """ Dummy object that just exists to hang __array_interface__ dictionaries + and possibly keep alive a reference to a base array. + """ + def __init__(self, interface, base=None): + self.__array_interface__ = interface + self.base = base + +def as_strided(x, shape=None, strides=None): + """ Make an ndarray from the given array with the given shape and strides. + """ + interface = dict(x.__array_interface__) + if shape is not None: + interface['shape'] = tuple(shape) + if strides is not None: + interface['strides'] = tuple(strides) + return np.asarray(DummyArray(interface, base=x)) + +def broadcast_arrays(*args): + """ Broadcast any number of arrays against each other. + + Parameters + ---------- + *args : arrays + + Returns + ------- + broadcasted : list of arrays + These arrays are views on the original arrays. They are typically not + contiguous. Furthermore, more than one element of a broadcasted array + may refer to a single memory location. If you need to write to the + arrays, make copies first. + + Examples + -------- + >>> x = np.array([[1,2,3]]) + >>> y = np.array([[1],[2],[3]]) + >>> np.broadcast_arrays(x, y) + [array([[1, 2, 3], + [1, 2, 3], + [1, 2, 3]]), array([[1, 1, 1], + [2, 2, 2], + [3, 3, 3]])] + + Here is a useful idiom for getting contiguous copies instead of + non-contiguous views. + + >>> map(np.array, np.broadcast_arrays(x, y)) + [array([[1, 2, 3], + [1, 2, 3], + [1, 2, 3]]), array([[1, 1, 1], + [2, 2, 2], + [3, 3, 3]])] + + """ + args = map(np.asarray, args) + shapes = [x.shape for x in args] + if len(set(shapes)) == 1: + # Common case where nothing needs to be broadcasted. + return args + shapes = [list(s) for s in shapes] + strides = [list(x.strides) for x in args] + nds = [len(s) for s in shapes] + biggest = max(nds) + # Go through each array and prepend dimensions of length 1 to each of the + # shapes in order to make the number of dimensions equal. + for i in range(len(args)): + diff = biggest - nds[i] + if diff > 0: + shapes[i] = [1] * diff + shapes[i] + strides[i] = [0] * diff + strides[i] + # Chech each dimension for compatibility. A dimension length of 1 is + # accepted as compatible with any other length. + common_shape = [] + for axis in range(biggest): + lengths = [s[axis] for s in shapes] + unique = set(lengths + [1]) + if len(unique) > 2: + # There must be at least two non-1 lengths for this axis. + raise ValueError("shape mismatch: two or more arrays have " + "incompatible dimensions on axis %r." % (axis,)) + elif len(unique) == 2: + # There is exactly one non-1 length. The common shape will take this + # value. + unique.remove(1) + new_length = unique.pop() + common_shape.append(new_length) + # For each array, if this axis is being broadcasted from a length of + # 1, then set its stride to 0 so that it repeats its data. + for i in range(len(args)): + if shapes[i][axis] == 1: + shapes[i][axis] = new_length + strides[i][axis] = 0 + else: + # Every array has a length of 1 on this axis. Strides can be left + # alone as nothing is broadcasted. + common_shape.append(1) + + # Construct the new arrays. + broadcasted = [as_strided(x, shape=sh, strides=st) for (x,sh,st) in + zip(args, shapes, strides)] + return broadcasted + Property changes on: trunk/numpy/lib/stride_tricks.py ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/numpy/lib/tests/test_stride_tricks.py =================================================================== --- trunk/numpy/lib/tests/test_stride_tricks.py 2008-07-03 06:23:15 UTC (rev 5340) +++ trunk/numpy/lib/tests/test_stride_tricks.py 2008-07-03 06:42:28 UTC (rev 5341) @@ -0,0 +1,206 @@ +from nose.tools import assert_raises +import numpy as np +from numpy.testing import assert_array_equal + +from numpy.lib.stride_tricks import broadcast_arrays + + +def assert_shapes_correct(input_shapes, expected_shape): + """ Broadcast a list of arrays with the given input shapes and check the + common output shape. + """ + inarrays = [np.zeros(s) for s in input_shapes] + outarrays = broadcast_arrays(*inarrays) + outshapes = [a.shape for a in outarrays] + expected = [expected_shape] * len(inarrays) + assert outshapes == expected + +def assert_incompatible_shapes_raise(input_shapes): + """ Broadcast a list of arrays with the given (incompatible) input shapes + and check that they raise a ValueError. + """ + inarrays = [np.zeros(s) for s in input_shapes] + assert_raises(ValueError, broadcast_arrays, *inarrays) + +def assert_same_as_ufunc(shape0, shape1, transposed=False, flipped=False): + """ Broadcast two shapes against each other and check that the data layout + is the same as if a ufunc did the broadcasting. + """ + x0 = np.zeros(shape0, dtype=int) + # Note that multiply.reduce's identity element is 1.0, so when shape1==(), + # this gives the desired n==1. + n = int(np.multiply.reduce(shape1)) + x1 = np.arange(n).reshape(shape1) + if transposed: + x0 = x0.T + x1 = x1.T + if flipped: + x0 = x0[::-1] + x1 = x1[::-1] + # Use the add ufunc to do the broadcasting. Since we're adding 0s to x1, the + # result should be exactly the same as the broadcasted view of x1. + y = x0 + x1 + b0, b1 = broadcast_arrays(x0, x1) + assert_array_equal(y, b1) + + +def test_same(): + x = np.arange(10) + y = np.arange(10) + bx, by = broadcast_arrays(x, y) + assert_array_equal(x, bx) + assert_array_equal(y, by) + +def test_one_off(): + x = np.array([[1,2,3]]) + y = np.array([[1],[2],[3]]) + bx, by = broadcast_arrays(x, y) + bx0 = np.array([[1,2,3],[1,2,3],[1,2,3]]) + by0 = bx0.T + assert_array_equal(bx0, bx) + assert_array_equal(by0, by) + +def test_same_input_shapes(): + """ Check that the final shape is just the input shape. + """ + data = [ + (), + (1,), + (3,), + (0,1), + (0,3), + (1,0), + (3,0), + (1,3), + (3,1), + (3,3), + ] + for shape in data: + input_shapes = [shape] + # Single input. + yield assert_shapes_correct, input_shapes, shape + # Double input. + input_shapes2 = [shape, shape] + yield assert_shapes_correct, input_shapes2, shape + # Triple input. + input_shapes3 = [shape, shape, shape] + yield assert_shapes_correct, input_shapes3, shape + +def test_two_compatible_by_ones_input_shapes(): + """ Check that two different input shapes (of the same length but some have + 1s) broadcast to the correct shape. + """ + data = [ + [[(1,), (3,)], (3,)], + [[(1,3), (3,3)], (3,3)], + [[(3,1), (3,3)], (3,3)], + [[(1,3), (3,1)], (3,3)], + [[(1,1), (3,3)], (3,3)], + [[(1,1), (1,3)], (1,3)], + [[(1,1), (3,1)], (3,1)], + [[(1,0), (0,0)], (0,0)], + [[(0,1), (0,0)], (0,0)], + [[(1,0), (0,1)], (0,0)], + [[(1,1), (0,0)], (0,0)], + [[(1,1), (1,0)], (1,0)], + [[(1,1), (0,1)], (0,1)], + ] + for input_shapes, expected_shape in data: + yield assert_shapes_correct, input_shapes, expected_shape + # Reverse the input shapes since broadcasting should be symmetric. + yield assert_shapes_correct, input_shapes[::-1], expected_shape + +def test_two_compatible_by_prepending_ones_input_shapes(): + """ Check that two different input shapes (of different lengths) broadcast + to the correct shape. + """ + data = [ + [[(), (3,)], (3,)], + [[(3,), (3,3)], (3,3)], + [[(3,), (3,1)], (3,3)], + [[(1,), (3,3)], (3,3)], + [[(), (3,3)], (3,3)], + [[(1,1), (3,)], (1,3)], + [[(1,), (3,1)], (3,1)], + [[(1,), (1,3)], (1,3)], + [[(), (1,3)], (1,3)], + [[(), (3,1)], (3,1)], + [[(), (0,)], (0,)], + [[(0,), (0,0)], (0,0)], + [[(0,), (0,1)], (0,0)], + [[(1,), (0,0)], (0,0)], + [[(), (0,0)], (0,0)], + [[(1,1), (0,)], (1,0)], + [[(1,), (0,1)], (0,1)], + [[(1,), (1,0)], (1,0)], + [[(), (1,0)], (1,0)], + [[(), (0,1)], (0,1)], + ] + for input_shapes, expected_shape in data: + yield assert_shapes_correct, input_shapes, expected_shape + # Reverse the input shapes since broadcasting should be symmetric. + yield assert_shapes_correct, input_shapes[::-1], expected_shape + +def test_incompatible_shapes_raise_valueerror(): + """ Check that a ValueError is raised for incompatible shapes. + """ + data = [ + [(3,), (4,)], + [(2,3), (2,)], + [(3,), (3,), (4,)], + [(1,3,4), (2,3,3)], + ] + for input_shapes in data: + yield assert_incompatible_shapes_raise, input_shapes + # Reverse the input shapes since broadcasting should be symmetric. + yield assert_incompatible_shapes_raise, input_shapes[::-1] + +def test_same_as_ufunc(): + """ Check that the data layout is the same as if a ufunc did the operation. + """ + data = [ + [[(1,), (3,)], (3,)], + [[(1,3), (3,3)], (3,3)], + [[(3,1), (3,3)], (3,3)], + [[(1,3), (3,1)], (3,3)], + [[(1,1), (3,3)], (3,3)], + [[(1,1), (1,3)], (1,3)], + [[(1,1), (3,1)], (3,1)], + [[(1,0), (0,0)], (0,0)], + [[(0,1), (0,0)], (0,0)], + [[(1,0), (0,1)], (0,0)], + [[(1,1), (0,0)], (0,0)], + [[(1,1), (1,0)], (1,0)], + [[(1,1), (0,1)], (0,1)], + [[(), (3,)], (3,)], + [[(3,), (3,3)], (3,3)], + [[(3,), (3,1)], (3,3)], + [[(1,), (3,3)], (3,3)], + [[(), (3,3)], (3,3)], + [[(1,1), (3,)], (1,3)], + [[(1,), (3,1)], (3,1)], + [[(1,), (1,3)], (1,3)], + [[(), (1,3)], (1,3)], + [[(), (3,1)], (3,1)], + [[(), (0,)], (0,)], + [[(0,), (0,0)], (0,0)], + [[(0,), (0,1)], (0,0)], + [[(1,), (0,0)], (0,0)], + [[(), (0,0)], (0,0)], + [[(1,1), (0,)], (1,0)], + [[(1,), (0,1)], (0,1)], + [[(1,), (1,0)], (1,0)], + [[(), (1,0)], (1,0)], + [[(), (0,1)], (0,1)], + ] + for input_shapes, expected_shape in data: + yield assert_same_as_ufunc, input_shapes[0], input_shapes[1] + # Reverse the input shapes since broadcasting should be symmetric. + yield assert_same_as_ufunc, input_shapes[1], input_shapes[0] + # Try them transposed, too. + yield assert_same_as_ufunc, input_shapes[0], input_shapes[1], True + # ... and flipped for non-rank-0 inputs in order to test negative + # strides. + if () not in input_shapes: + yield assert_same_as_ufunc, input_shapes[0], input_shapes[1], False, True + yield assert_same_as_ufunc, input_shapes[0], input_shapes[1], True, True Property changes on: trunk/numpy/lib/tests/test_stride_tricks.py ___________________________________________________________________ Name: svn:eol-style + native From numpy-svn at scipy.org Thu Jul 3 02:59:31 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 01:59:31 -0500 (CDT) Subject: [Numpy-svn] r5342 - in trunk/numpy/lib: . tests Message-ID: <20080703065931.9D0CE39C678@scipy.org> Author: rkern Date: 2008-07-03 01:59:29 -0500 (Thu, 03 Jul 2008) New Revision: 5342 Modified: trunk/numpy/lib/_datasource.py trunk/numpy/lib/tests/test__datasource.py Log: BUG: need to create exceptions correctly. Modified: trunk/numpy/lib/_datasource.py =================================================================== --- trunk/numpy/lib/_datasource.py 2008-07-03 06:42:28 UTC (rev 5341) +++ trunk/numpy/lib/_datasource.py 2008-07-03 06:59:29 UTC (rev 5342) @@ -211,14 +211,14 @@ openedurl = urlopen(path) file(upath, 'w').write(openedurl.read()) except URLError: - raise URLError("URL not found: ", path) + raise URLError("URL not found: %s" % path) else: try: # TODO: Why not just copy the file with shutils.copyfile? fp = file(path, 'r') file(upath, 'w').write(fp.read()) except IOError: - raise IOError("File not found: ", path) + raise IOError("File not found: %s" % path) return upath def _findfile(self, path): Modified: trunk/numpy/lib/tests/test__datasource.py =================================================================== --- trunk/numpy/lib/tests/test__datasource.py 2008-07-03 06:42:28 UTC (rev 5341) +++ trunk/numpy/lib/tests/test__datasource.py 2008-07-03 06:59:29 UTC (rev 5342) @@ -81,8 +81,17 @@ assert self.ds.open(valid_httpurl()) def test_InvalidHTTP(self): - self.assertRaises(IOError, self.ds.open, invalid_httpurl()) + url = invalid_httpurl() + self.assertRaises(IOError, self.ds.open, url) + try: + self.ds.open(url) + except IOError, e: + # Regression test for bug fixed in r4342. + assert e.errno is None + def test_InvalidHTTPCacheURLError(self): + self.assertRaises(URLError, self.ds._cache, invalid_httpurl()) + def test_ValidFile(self): local_file = valid_textfile(self.tmpdir) assert self.ds.open(local_file) @@ -95,10 +104,9 @@ try: import gzip except ImportError: - # We don't have the bz2 capabilities to test. - # FIXME: when we start using nose, raise a SkipTest rather than - # passing the test. - return + # We don't have the gzip capabilities to test. + import nose + raise nose.SkipTest # Test datasource's internal file_opener for Gzip files. filepath = os.path.join(self.tmpdir, 'foobar.txt.gz') fp = gzip.open(filepath, 'w') @@ -114,9 +122,8 @@ import bz2 except ImportError: # We don't have the bz2 capabilities to test. - # FIXME: when we start using nose, raise a SkipTest rather than - # passing the test. - return + import nose + raise nose.SkipTest # Test datasource's internal file_opener for BZip2 files. filepath = os.path.join(self.tmpdir, 'foobar.txt.bz2') fp = bz2.BZ2File(filepath, 'w') @@ -288,7 +295,6 @@ tmpfile = valid_textfile(local_path) assert self.repos.exists(tmpfile) - class TestOpenFunc(TestCase): def setUp(self): self.tmpdir = mkdtemp() From numpy-svn at scipy.org Thu Jul 3 04:44:10 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 03:44:10 -0500 (CDT) Subject: [Numpy-svn] r5343 - in trunk/numpy: core/tests distutils/tests doc f2py/lib f2py/lib/parser f2py/lib/tests fft/tests lib/tests linalg/tests oldnumeric/tests Message-ID: <20080703084410.AA03E39C7B1@scipy.org> Author: rkern Date: 2008-07-03 03:43:58 -0500 (Thu, 03 Jul 2008) New Revision: 5343 Modified: trunk/numpy/core/tests/test_regression.py trunk/numpy/distutils/tests/test_fcompiler_gnu.py trunk/numpy/doc/DISTUTILS.txt trunk/numpy/f2py/lib/__init__.py trunk/numpy/f2py/lib/parser/Fortran2003.py trunk/numpy/f2py/lib/parser/test_Fortran2003.py trunk/numpy/f2py/lib/tests/test_derived_scalar.py trunk/numpy/f2py/lib/tests/test_module_module.py trunk/numpy/f2py/lib/tests/test_module_scalar.py trunk/numpy/f2py/lib/tests/test_scalar_function_in.py trunk/numpy/f2py/lib/tests/test_scalar_in_out.py trunk/numpy/fft/tests/test_fftpack.py trunk/numpy/fft/tests/test_helper.py trunk/numpy/lib/tests/test_function_base.py trunk/numpy/linalg/tests/test_linalg.py trunk/numpy/linalg/tests/test_regression.py trunk/numpy/oldnumeric/tests/test_oldnumeric.py Log: Clean up test output such that a completely-passing test suite has no extraneous output. Modified: trunk/numpy/core/tests/test_regression.py =================================================================== --- trunk/numpy/core/tests/test_regression.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/core/tests/test_regression.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -807,9 +807,14 @@ def test_hist_bins_as_list(self, level=rlevel): """Ticket #632""" - hist,edges = np.histogram([1,2,3,4],[1,2]) - assert_array_equal(hist,[1,3]) - assert_array_equal(edges,[1,2]) + import warnings + warnings.simplefilter('ignore', FutureWarning) + try: + hist,edges = np.histogram([1,2,3,4],[1,2]) + assert_array_equal(hist,[1,3]) + assert_array_equal(edges,[1,2]) + finally: + warnings.resetwarnings() def test_copy_detection_zero_dim(self, level=rlevel): """Ticket #658""" Modified: trunk/numpy/distutils/tests/test_fcompiler_gnu.py =================================================================== --- trunk/numpy/distutils/tests/test_fcompiler_gnu.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/distutils/tests/test_fcompiler_gnu.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -1,8 +1,6 @@ from numpy.testing import * -set_package_path() import numpy.distutils.fcompiler -restore_path() g77_version_strings = [ ('GNU Fortran 0.5.25 20010319 (prerelease)', '0.5.25'), Modified: trunk/numpy/doc/DISTUTILS.txt =================================================================== --- trunk/numpy/doc/DISTUTILS.txt 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/doc/DISTUTILS.txt 2008-07-03 08:43:58 UTC (rev 5343) @@ -477,15 +477,9 @@ import sys from numpy.testing import * - set_package_path() # import xxx symbols - from xxx.yyy import zzz - restore_path() + from numpy.xxx.yyy import zzz - #Optional: - set_local_path() - # import modules that are located in the same directory as this file. - restore_path() class test_zzz(TestCase): def test_simple(self, level=1): Modified: trunk/numpy/f2py/lib/__init__.py =================================================================== --- trunk/numpy/f2py/lib/__init__.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/f2py/lib/__init__.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -12,3 +12,4 @@ Created: Oct 2006 ----- """ +__test__ = False Modified: trunk/numpy/f2py/lib/parser/Fortran2003.py =================================================================== --- trunk/numpy/f2py/lib/parser/Fortran2003.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/f2py/lib/parser/Fortran2003.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -5826,7 +5826,7 @@ def _rpl_list(clsname): if clsname not in Base_classes: - print 'Not implemented:',clsname + #print 'Not implemented:',clsname return [] # remove this code when all classes are implemented cls = Base_classes[clsname] if 'match' in cls.__dict__: @@ -5868,7 +5868,7 @@ else: print '%s not implemented needed by %s' % (n,clsname) -if 1: +if False: for cls in Base_classes.values(): subclasses = Base.subclasses.get(cls.__name__,[]) subclasses_names = [c.__name__ for c in subclasses] Modified: trunk/numpy/f2py/lib/parser/test_Fortran2003.py =================================================================== --- trunk/numpy/f2py/lib/parser/test_Fortran2003.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/f2py/lib/parser/test_Fortran2003.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -2056,7 +2056,7 @@ assert_equal(str(a),'CONTAINS') assert_equal(repr(a),"Contains_Stmt('CONTAINS')") -if 1: +if False: nof_needed_tests = 0 nof_needed_match = 0 total_needs = 0 Modified: trunk/numpy/f2py/lib/tests/test_derived_scalar.py =================================================================== --- trunk/numpy/f2py/lib/tests/test_derived_scalar.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/f2py/lib/tests/test_derived_scalar.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -15,9 +15,7 @@ import os import sys from numpy.testing import * -set_package_path() -from lib.main import build_extension, compile -restore_path() +from numpy.f2py.lib.main import build_extension, compile fortran_code = ''' subroutine foo(a) Modified: trunk/numpy/f2py/lib/tests/test_module_module.py =================================================================== --- trunk/numpy/f2py/lib/tests/test_module_module.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/f2py/lib/tests/test_module_module.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -16,9 +16,7 @@ import sys from numpy.testing import * -set_package_path() -from lib.main import build_extension, compile -restore_path() +from numpy.f2py.lib.main import build_extension, compile fortran_code = ''' module test_module_module_ext2 Modified: trunk/numpy/f2py/lib/tests/test_module_scalar.py =================================================================== --- trunk/numpy/f2py/lib/tests/test_module_scalar.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/f2py/lib/tests/test_module_scalar.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -15,9 +15,7 @@ import os import sys from numpy.testing import * -set_package_path() -from lib.main import build_extension, compile -restore_path() +from numpy.f2py.lib.main import build_extension, compile fortran_code = ''' module test_module_scalar_ext Modified: trunk/numpy/f2py/lib/tests/test_scalar_function_in.py =================================================================== --- trunk/numpy/f2py/lib/tests/test_scalar_function_in.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/f2py/lib/tests/test_scalar_function_in.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -16,9 +16,7 @@ import sys from numpy.testing import * -set_package_path() -from lib.main import build_extension, compile -restore_path() +from numpy.f2py.lib.main import build_extension, compile fortran_code = '''\ ! -*- f77 -*- Modified: trunk/numpy/f2py/lib/tests/test_scalar_in_out.py =================================================================== --- trunk/numpy/f2py/lib/tests/test_scalar_in_out.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/f2py/lib/tests/test_scalar_in_out.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -16,9 +16,7 @@ import sys from numpy.testing import * -set_package_path() -from lib.main import build_extension, compile -restore_path() +from numpy.f2py.lib.main import build_extension, compile fortran_code = ''' subroutine fooint1(a) Modified: trunk/numpy/fft/tests/test_fftpack.py =================================================================== --- trunk/numpy/fft/tests/test_fftpack.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/fft/tests/test_fftpack.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -1,8 +1,6 @@ import sys from numpy.testing import * -set_package_path() import numpy as np -restore_path() def fft1(x): L = len(x) Modified: trunk/numpy/fft/tests/test_helper.py =================================================================== --- trunk/numpy/fft/tests/test_helper.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/fft/tests/test_helper.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -5,9 +5,7 @@ import sys from numpy.testing import * -set_package_path() from numpy.fft import fftshift,ifftshift,fftfreq -restore_path() from numpy import pi Modified: trunk/numpy/lib/tests/test_function_base.py =================================================================== --- trunk/numpy/lib/tests/test_function_base.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/lib/tests/test_function_base.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -1,4 +1,5 @@ import sys +import warnings from numpy.testing import * import numpy.lib @@ -425,8 +426,12 @@ assert_array_almost_equal(w,flipud(w),7) class TestHistogram(TestCase): - import warnings - warnings.simplefilter('ignore', FutureWarning) + def setUp(self): + warnings.simplefilter('ignore', FutureWarning) + + def tearDown(self): + warnings.resetwarnings() + def test_simple(self): n=100 v=rand(n) Modified: trunk/numpy/linalg/tests/test_linalg.py =================================================================== --- trunk/numpy/linalg/tests/test_linalg.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/linalg/tests/test_linalg.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -2,12 +2,10 @@ """ from numpy.testing import * -set_package_path() from numpy import array, single, double, csingle, cdouble, dot, identity from numpy import multiply, atleast_2d, inf, asarray, matrix from numpy import linalg -from linalg import matrix_power -restore_path() +from numpy.linalg import matrix_power def ifthen(a, b): return not a or b Modified: trunk/numpy/linalg/tests/test_regression.py =================================================================== --- trunk/numpy/linalg/tests/test_regression.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/linalg/tests/test_regression.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -2,10 +2,8 @@ """ from numpy.testing import * -set_package_path() import numpy as np from numpy import linalg, arange, float64, array, dot, transpose -restore_path() rlevel = 1 Modified: trunk/numpy/oldnumeric/tests/test_oldnumeric.py =================================================================== --- trunk/numpy/oldnumeric/tests/test_oldnumeric.py 2008-07-03 06:59:29 UTC (rev 5342) +++ trunk/numpy/oldnumeric/tests/test_oldnumeric.py 2008-07-03 08:43:58 UTC (rev 5343) @@ -1,3 +1,5 @@ +import unittest + from numpy.testing import * from numpy import array @@ -5,7 +7,7 @@ from numpy.core.numeric import float32, float64, complex64, complex128, int8, \ int16, int32, int64, uint, uint8, uint16, uint32, uint64 -class test_oldtypes(NumPyTestCase): +class test_oldtypes(unittest.TestCase): def test_oldtypes(self, level=1): a1 = array([0,1,0], Float) a2 = array([0,1,0], float) From numpy-svn at scipy.org Thu Jul 3 12:28:01 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 11:28:01 -0500 (CDT) Subject: [Numpy-svn] r5344 - branches/1.1.x/numpy/ma Message-ID: <20080703162801.782B839C7DE@scipy.org> Author: pierregm Date: 2008-07-03 11:27:58 -0500 (Thu, 03 Jul 2008) New Revision: 5344 Modified: branches/1.1.x/numpy/ma/core.py Log: substitute getattr(...,...)(*args,**kwargs) for getattr(...,...).__call__(*args,**kwargs) in _frommethods Modified: branches/1.1.x/numpy/ma/core.py =================================================================== --- branches/1.1.x/numpy/ma/core.py 2008-07-03 08:43:58 UTC (rev 5343) +++ branches/1.1.x/numpy/ma/core.py 2008-07-03 16:27:58 UTC (rev 5344) @@ -3126,7 +3126,7 @@ return getattr(np, self._methodname).__doc__ def __call__(self, a, *args, **params): if isinstance(a, MaskedArray): - return getattr(a, self._methodname).__call__(*args, **params) + return getattr(a, self._methodname)(*args, **params) #FIXME ---- #As x is not a MaskedArray, we transform it to a ndarray with asarray #... and call the corresponding method. From numpy-svn at scipy.org Thu Jul 3 12:29:37 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 11:29:37 -0500 (CDT) Subject: [Numpy-svn] r5345 - branches/1.1.x/numpy/ma Message-ID: <20080703162937.F22DC39C5A1@scipy.org> Author: pierregm Date: 2008-07-03 11:29:36 -0500 (Thu, 03 Jul 2008) New Revision: 5345 Modified: branches/1.1.x/numpy/ma/core.py Log: Avoid updating the __dict__ of the result in .reshape Modified: branches/1.1.x/numpy/ma/core.py =================================================================== --- branches/1.1.x/numpy/ma/core.py 2008-07-03 16:27:58 UTC (rev 5344) +++ branches/1.1.x/numpy/ma/core.py 2008-07-03 16:29:36 UTC (rev 5345) @@ -1867,10 +1867,10 @@ """ result = self._data.reshape(*s).view(type(self)) - result.__dict__.update(self.__dict__) - if result._mask is not nomask: - result._mask = self._mask.copy() - result._mask.shape = result.shape + result._update_from(self) + mask = self._mask + if mask is not nomask: + result._mask = mask.reshape(*s) return result # def resize(self, newshape, refcheck=True, order=False): From numpy-svn at scipy.org Thu Jul 3 15:02:18 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 14:02:18 -0500 (CDT) Subject: [Numpy-svn] r5346 - in trunk/numpy/lib: . tests Message-ID: <20080703190218.BDAF939C11D@scipy.org> Author: rkern Date: 2008-07-03 14:02:15 -0500 (Thu, 03 Jul 2008) New Revision: 5346 Modified: trunk/numpy/lib/_datasource.py trunk/numpy/lib/tests/test__datasource.py Log: BUG: Correctly stub out urllib2.urlopen() for tests given the refactoring of the local imports. Modified: trunk/numpy/lib/_datasource.py =================================================================== --- trunk/numpy/lib/_datasource.py 2008-07-03 16:29:36 UTC (rev 5345) +++ trunk/numpy/lib/_datasource.py 2008-07-03 19:02:15 UTC (rev 5346) @@ -341,7 +341,7 @@ """ # We import this here because importing urllib2 is slow and # a significant fraction of numpy's total import time. - from urllib2 import URLError + from urllib2 import urlopen, URLError # Test local path if os.path.exists(path): Modified: trunk/numpy/lib/tests/test__datasource.py =================================================================== --- trunk/numpy/lib/tests/test__datasource.py 2008-07-03 16:29:36 UTC (rev 5345) +++ trunk/numpy/lib/tests/test__datasource.py 2008-07-03 19:02:15 UTC (rev 5346) @@ -6,6 +6,7 @@ from shutil import rmtree from urlparse import urlparse from urllib2 import URLError +import urllib2 from numpy.testing import * @@ -19,10 +20,15 @@ else: raise URLError('Name or service not known') -# Rebind urlopen during testing. For a 'real' test, uncomment the rebinding -# below. -datasource.urlopen = urlopen_stub +old_urlopen = None +def setup(): + global old_urlopen + old_urlopen = urllib2.urlopen + urllib2.urlopen = urlopen_stub +def teardown(): + urllib2.urlopen = old_urlopen + # A valid website for more robust testing http_path = 'http://www.google.com/' http_file = 'index.html' From numpy-svn at scipy.org Thu Jul 3 15:57:26 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 14:57:26 -0500 (CDT) Subject: [Numpy-svn] r5347 - trunk/numpy/f2py Message-ID: <20080703195726.74D0239C09B@scipy.org> Author: rkern Date: 2008-07-03 14:57:24 -0500 (Thu, 03 Jul 2008) New Revision: 5347 Removed: trunk/numpy/f2py/lib/ Modified: trunk/numpy/f2py/f2py2e.py trunk/numpy/f2py/setup.py trunk/numpy/f2py/setupscons.py Log: Removing G3 f2py code. Development has moved to https://launchpad.net/f2py/ Modified: trunk/numpy/f2py/f2py2e.py =================================================================== --- trunk/numpy/f2py/f2py2e.py 2008-07-03 19:02:15 UTC (rev 5346) +++ trunk/numpy/f2py/f2py2e.py 2008-07-03 19:57:24 UTC (rev 5347) @@ -69,11 +69,11 @@ Options: - --g3-numpy Use numpy.f2py.lib tool, the 3rd generation of F2PY, - with NumPy support. --2d-numpy Use numpy.f2py tool with NumPy support. [DEFAULT] --2d-numeric Use f2py2e tool with Numeric support. --2d-numarray Use f2py2e tool with Numarray support. + --g3-numpy Use 3rd generation f2py from the separate f2py package. + [NOT AVAILABLE YET] -h Write signatures of the fortran routines to file and exit. You can then edit and use it instead Modified: trunk/numpy/f2py/setup.py =================================================================== --- trunk/numpy/f2py/setup.py 2008-07-03 19:02:15 UTC (rev 5346) +++ trunk/numpy/f2py/setup.py 2008-07-03 19:57:24 UTC (rev 5347) @@ -63,10 +63,8 @@ except ValueError: pass os.environ["NO_SCIPY_IMPORT"]="f2py" if mode=="g3-numpy": - try: - from main import main - except ImportError: - from numpy.f2py.lib.api import main + print >> sys.stderr, "G3 f2py support is not implemented, yet." + sys.exit(1) elif mode=="2e-numeric": from f2py2e import main elif mode=="2e-numarray": Modified: trunk/numpy/f2py/setupscons.py =================================================================== --- trunk/numpy/f2py/setupscons.py 2008-07-03 19:02:15 UTC (rev 5346) +++ trunk/numpy/f2py/setupscons.py 2008-07-03 19:57:24 UTC (rev 5347) @@ -63,10 +63,8 @@ except ValueError: pass os.environ["NO_SCIPY_IMPORT"]="f2py" if mode=="g3-numpy": - try: - from main import main - except ImportError: - from numpy.f2py.lib.api import main + print >> sys.stderr, "G3 f2py support is not implemented, yet." + sys.exit(1) elif mode=="2e-numeric": from f2py2e import main elif mode=="2e-numarray": From numpy-svn at scipy.org Thu Jul 3 16:01:39 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 15:01:39 -0500 (CDT) Subject: [Numpy-svn] r5348 - in trunk/numpy: f2py testing Message-ID: <20080703200139.060F339C3AB@scipy.org> Author: rkern Date: 2008-07-03 15:01:36 -0500 (Thu, 03 Jul 2008) New Revision: 5348 Modified: trunk/numpy/f2py/setup.py trunk/numpy/testing/nosetester.py Log: Fix setup script. Exclude test that requires building from the main test suite. Modified: trunk/numpy/f2py/setup.py =================================================================== --- trunk/numpy/f2py/setup.py 2008-07-03 19:57:24 UTC (rev 5347) +++ trunk/numpy/f2py/setup.py 2008-07-03 20:01:36 UTC (rev 5348) @@ -30,8 +30,6 @@ def configuration(parent_package='',top_path=None): config = Configuration('f2py', parent_package, top_path) - config.add_subpackage('lib') - config.add_data_dir('docs') config.add_data_files('src/fortranobject.c', Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-03 19:57:24 UTC (rev 5347) +++ trunk/numpy/testing/nosetester.py 2008-07-03 20:01:36 UTC (rev 5348) @@ -318,6 +318,7 @@ argv += ['--exclude','gen_ext'] argv += ['--exclude','pyrex_ext'] argv += ['--exclude','swig_ext'] + argv += ['--exclude','array_from_pyobj'] nose = import_nose() From numpy-svn at scipy.org Thu Jul 3 16:21:21 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 3 Jul 2008 15:21:21 -0500 (CDT) Subject: [Numpy-svn] r5349 - in trunk/numpy/oldnumeric: . tests Message-ID: <20080703202121.5B1E639C09B@scipy.org> Author: rkern Date: 2008-07-03 15:21:20 -0500 (Thu, 03 Jul 2008) New Revision: 5349 Modified: trunk/numpy/oldnumeric/precision.py trunk/numpy/oldnumeric/setup.py trunk/numpy/oldnumeric/tests/test_oldnumeric.py Log: Correct the oldnumeric typecodes, update the tests to work on 32-bit machines, make sure these tests are installed with numpy so they can be run with numpy.test(). Modified: trunk/numpy/oldnumeric/precision.py =================================================================== --- trunk/numpy/oldnumeric/precision.py 2008-07-03 20:01:36 UTC (rev 5348) +++ trunk/numpy/oldnumeric/precision.py 2008-07-03 20:21:20 UTC (rev 5349) @@ -5,12 +5,12 @@ __all__ = ['Character', 'Complex', 'Float', 'PrecisionError', 'PyObject', 'Int', 'UInt', - 'UnsignedInteger', 'string', 'typecodes', 'zeros'] + 'UnsignedInt', 'UnsignedInteger', 'string', 'typecodes', 'zeros'] from functions import zeros import string # for backwards compatibility -typecodes = {'Character':'c', 'Integer':'bhil', 'UnsignedInteger':'BHI', 'Float':'fd', 'Complex':'FD'} +typecodes = {'Character':'c', 'Integer':'bhil', 'UnsignedInteger':'BHIL', 'Float':'fd', 'Complex':'FD'} def _get_precisions(typecodes): lst = [] @@ -67,8 +67,7 @@ __all__.extend(['UnsignedInt128', 'UInt128']) except(PrecisionError): pass -UnsignedInteger = 'u' -UInt = UnsignedInteger +UInt = UnsignedInt = UnsignedInteger = 'u' try: Int0 = _lookup(_code_table, 'Integer', 0) Modified: trunk/numpy/oldnumeric/setup.py =================================================================== --- trunk/numpy/oldnumeric/setup.py 2008-07-03 20:01:36 UTC (rev 5348) +++ trunk/numpy/oldnumeric/setup.py 2008-07-03 20:21:20 UTC (rev 5349) @@ -1,7 +1,9 @@ def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - return Configuration('oldnumeric',parent_package,top_path) + config = Configuration('oldnumeric',parent_package,top_path) + config.add_data_dir('tests') + return config if __name__ == '__main__': from numpy.distutils.core import setup Modified: trunk/numpy/oldnumeric/tests/test_oldnumeric.py =================================================================== --- trunk/numpy/oldnumeric/tests/test_oldnumeric.py 2008-07-03 20:01:36 UTC (rev 5348) +++ trunk/numpy/oldnumeric/tests/test_oldnumeric.py 2008-07-03 20:21:20 UTC (rev 5349) @@ -51,9 +51,13 @@ a1 = array([0,1,0], Int32) a2 = array([0,1,0], int32) assert_array_equal(a1, a2) - a1 = array([0,1,0], Int64) - a2 = array([0,1,0], int64) - assert_array_equal(a1, a2) + try: + a1 = array([0,1,0], Int64) + a2 = array([0,1,0], int64) + assert_array_equal(a1, a2) + except NameError: + # Not all systems have 64-bit integers. + pass a1 = array([0,1,0], UnsignedInt) a2 = array([0,1,0], UnsignedInteger) a3 = array([0,1,0], uint) @@ -74,15 +78,17 @@ a3 = array([0,1,0], uint32) assert_array_equal(a1, a3) assert_array_equal(a2, a3) - a1 = array([0,1,0], UInt64) - a2 = array([0,1,0], UnsignedInt64) - a3 = array([0,1,0], uint64) - assert_array_equal(a1, a3) - assert_array_equal(a2, a3) - a1 = array([0,1,0], Bool) - a2 = array([0,1,0], bool) - assert_array_equal(a1, a2) + try: + a1 = array([0,1,0], UInt64) + a2 = array([0,1,0], UnsignedInt64) + a3 = array([0,1,0], uint64) + assert_array_equal(a1, a3) + assert_array_equal(a2, a3) + except NameError: + # Not all systems have 64-bit integers. + pass if __name__ == "__main__": - run_module_suite() + import nose + nose.main() From numpy-svn at scipy.org Fri Jul 4 21:17:10 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 4 Jul 2008 20:17:10 -0500 (CDT) Subject: [Numpy-svn] r5350 - trunk/numpy/core/src Message-ID: <20080705011710.E31EEC7C02E@scipy.org> Author: rkern Date: 2008-07-04 20:17:03 -0500 (Fri, 04 Jul 2008) New Revision: 5350 Modified: trunk/numpy/core/src/umathmodule.c.src Log: BUG: C-style /**/ comments only. Modified: trunk/numpy/core/src/umathmodule.c.src =================================================================== --- trunk/numpy/core/src/umathmodule.c.src 2008-07-03 20:21:20 UTC (rev 5349) +++ trunk/numpy/core/src/umathmodule.c.src 2008-07-05 01:17:03 UTC (rev 5350) @@ -1515,7 +1515,7 @@ n=dimensions[0]; for(i=0; i Author: alan.mcintyre Date: 2008-07-05 09:26:16 -0500 (Sat, 05 Jul 2008) New Revision: 5351 Modified: trunk/numpy/add_newdocs.py trunk/numpy/lib/financial.py trunk/numpy/lib/function_base.py trunk/numpy/lib/io.py trunk/numpy/lib/polynomial.py trunk/numpy/lib/scimath.py trunk/numpy/lib/shape_base.py trunk/numpy/lib/twodim_base.py trunk/numpy/linalg/linalg.py trunk/numpy/ma/core.py trunk/numpy/ma/extras.py trunk/numpy/testing/decorators.py Log: Use the implicit "import numpy as np" made available to all doctests instead of explicit imports or dependency on the local scope where the doctest is defined.. Modified: trunk/numpy/add_newdocs.py =================================================================== --- trunk/numpy/add_newdocs.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/add_newdocs.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -19,46 +19,46 @@ -------- Using array-scalar type: ->>> dtype(int16) +>>> np.dtype(np.int16) dtype('int16') Record, one field name 'f1', containing int16: ->>> dtype([('f1', int16)]) +>>> np.dtype([('f1', np.int16)]) dtype([('f1', '>> dtype([('f1', [('f1', int16)])]) +>>> np.dtype([('f1', [('f1', np.int16)])]) dtype([('f1', [('f1', '>> dtype([('f1', uint), ('f2', int32)]) +>>> np.dtype([('f1', np.uint), ('f2', np.int32)]) dtype([('f1', '>> dtype([('a','f8'),('b','S10')]) +>>> np.dtype([('a','f8'),('b','S10')]) dtype([('a', '>> dtype("i4, (2,3)f8") +>>> np.dtype("i4, (2,3)f8") dtype([('f0', '>> dtype([('hello',(int,3)),('world',void,10)]) +>>> np.dtype([('hello',(np.int,3)),('world',np.void,10)]) dtype([('hello', '>> dtype((int16, {'x':(int8,0), 'y':(int8,1)})) +>>> np.dtype((np.int16, {'x':(np.int8,0), 'y':(np.int8,1)})) dtype(('>> dtype({'names':['gender','age'], 'formats':['S1',uint8]}) +>>> np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]}) dtype([('gender', '|S1'), ('age', '|u1')]) Offsets in bytes, here 0 and 25: ->>> dtype({'surname':('S25',0),'age':(uint8,25)}) +>>> np.dtype({'surname':('S25',0),'age':(np.uint8,25)}) dtype([('surname', '|S25'), ('age', '|u1')]) """) @@ -386,7 +386,7 @@ Examples -------- - >>> concatenate( ([0,1,2], [5,6,7]) ) + >>> np.concatenate( ([0,1,2], [5,6,7]) ) array([0, 1, 2, 5, 6, 7]) """) @@ -480,7 +480,7 @@ Examples -------- - >>> where([True,False,True],[1,2,3],[4,5,6]) + >>> np.where([True,False,True],[1,2,3],[4,5,6]) array([1, 5, 3]) """) @@ -520,12 +520,12 @@ -------- >>> a = [1,5,1,4,3,6,7] >>> b = [9,4,0,4,0,4,3] - >>> ind = lexsort((b,a)) + >>> ind = np.lexsort((b,a)) >>> print ind [2 0 4 3 1 5 6] - >>> print take(a,ind) + >>> print np.take(a,ind) [1 1 3 4 5 6 7] - >>> print take(b,ind) + >>> print np.take(b,ind) [0 9 0 4 4 4 3] """) @@ -858,7 +858,7 @@ Examples -------- - >>> a = arange(6).reshape(2,3) + >>> a = np.arange(6).reshape(2,3) >>> a.argmax() 5 >>> a.argmax(0) @@ -889,7 +889,7 @@ Examples -------- - >>> a = arange(6).reshape(2,3) + >>> a = np.arange(6).reshape(2,3) >>> a.argmin() 0 >>> a.argmin(0) @@ -1008,10 +1008,10 @@ -------- >>> choices = [[0, 1, 2, 3], [10, 11, 12, 13], ... [20, 21, 22, 23], [30, 31, 32, 33]] - >>> a = array([2, 3, 1, 0], dtype=int) + >>> a = np.array([2, 3, 1, 0], dtype=int) >>> a.choose(choices) array([20, 31, 12, 3]) - >>> a = array([2, 4, 1, 0], dtype=int) + >>> a = np.array([2, 4, 1, 0], dtype=int) >>> a.choose(choices, mode='clip') array([20, 31, 12, 3]) >>> a.choose(choices, mode='wrap') @@ -1226,7 +1226,7 @@ Examples -------- - >>> a = arange(4).reshape(2,2) + >>> a = np.arange(4).reshape(2,2) >>> a array([[0, 1], [2, 3]]) @@ -1235,7 +1235,7 @@ >>> a.diagonal(1) array([1]) - >>> a = arange(8).reshape(2,2,2) + >>> a = np.arange(8).reshape(2,2,2) >>> a array([[[0, 1], [2, 3]], @@ -1462,13 +1462,13 @@ Examples -------- - >>> prod([1.,2.]) + >>> np.prod([1.,2.]) 2.0 - >>> prod([1.,2.], dtype=int32) + >>> np.prod([1.,2.], dtype=np.int32) 2 - >>> prod([[1.,2.],[3.,4.]]) + >>> np.prod([[1.,2.],[3.,4.]]) 24.0 - >>> prod([[1.,2.],[3.,4.]], axis=1) + >>> np.prod([[1.,2.],[3.,4.]], axis=1) array([ 2., 12.]) Notes @@ -1599,7 +1599,7 @@ Examples -------- - >>> x = array([[1,2,3],[4,5,6]]) + >>> x = np.array([[1,2,3],[4,5,6]]) >>> x array([[1, 2, 3], [4, 5, 6]]) @@ -1637,7 +1637,7 @@ Examples -------- - >>> x = array([[1,2],[3,4]]) + >>> x = np.array([[1,2],[3,4]]) >>> x.repeat(2) array([1, 1, 2, 2, 3, 3, 4, 4]) >>> x.repeat(3, axis=1) @@ -1725,10 +1725,10 @@ Examples -------- - >>> x = array([.5, 1.5, 2.5, 3.5, 4.5]) + >>> x = np.array([.5, 1.5, 2.5, 3.5, 4.5]) >>> x.round() array([ 0., 2., 2., 4., 4.]) - >>> x = array([1,2,3,11]) + >>> x = np.array([1,2,3,11]) >>> x.round(decimals=1) array([ 1, 2, 3, 11]) >>> x.round(decimals=-1) @@ -1840,7 +1840,7 @@ Examples -------- - >>> x = array([[[1,1,1],[2,2,2],[3,3,3]]]) + >>> x = np.array([[[1,1,1],[2,2,2],[3,3,3]]]) >>> x.shape (1, 3, 3) >>> x.squeeze().shape @@ -1929,15 +1929,15 @@ Examples -------- - >>> array([0.5, 1.5]).sum() + >>> np.array([0.5, 1.5]).sum() 2.0 - >>> array([0.5, 1.5]).sum(dtype=int32) + >>> np.array([0.5, 1.5]).sum(dtype=np.int32) 1 - >>> array([[0, 1], [0, 5]]).sum(axis=0) + >>> np.array([[0, 1], [0, 5]]).sum(axis=0) array([0, 6]) - >>> array([[0, 1], [0, 5]]).sum(axis=1) + >>> np.array([[0, 1], [0, 5]]).sum(axis=1) array([1, 5]) - >>> ones(128, dtype=int8).sum(dtype=int8) # overflow! + >>> np.ones(128, dtype=np.int8).sum(dtype=np.int8) # overflow! -128 Notes @@ -2120,9 +2120,9 @@ Examples -------- - >>> eye(3).trace() + >>> np.eye(3).trace() 3.0 - >>> a = arange(8).reshape((2,2,2)) + >>> a = np.arange(8).reshape((2,2,2)) >>> a.trace() array([6, 8]) @@ -2139,7 +2139,7 @@ Examples -------- - >>> a = array([[1,2],[3,4]]) + >>> a = np.array([[1,2],[3,4]]) >>> a array([[1, 2], [3, 4]]) Modified: trunk/numpy/lib/financial.py =================================================================== --- trunk/numpy/lib/financial.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/lib/financial.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -69,7 +69,7 @@ an additional monthly savings of $100. Assume the interest rate is 5% (annually) compounded monthly? ->>> fv(0.05/12, 10*12, -100, -100) +>>> np.fv(0.05/12, 10*12, -100, -100) 15692.928894335748 By convention, the negative sign represents cash flow out (i.e. money not @@ -94,7 +94,7 @@ What would the monthly payment need to be to pay off a $200,000 loan in 15 years at an annual interest rate of 7.5%? ->>> pmt(0.075/12, 12*15, 200000) +>>> np.pmt(0.075/12, 12*15, 200000) -1854.0247200054619 In order to pay-off (i.e. have a future-value of 0) the $200,000 obtained @@ -122,7 +122,7 @@ If you only had $150 to spend as payment, how long would it take to pay-off a loan of $8,000 at 7% annual interest? ->>> nper(0.07/12, -150, 8000) +>>> np.nper(0.07/12, -150, 8000) 64.073348770661852 So, over 64 months would be required to pay off the loan. @@ -130,7 +130,7 @@ The same analysis could be done with several different interest rates and/or payments and/or total amounts to produce an entire table. ->>> nper(*(ogrid[0.06/12:0.071/12:0.01/12, -200:-99:100, 6000:7001:1000])) +>>> np.nper(*(np.ogrid[0.06/12:0.071/12:0.01/12, -200:-99:100, 6000:7001:1000])) array([[[ 32.58497782, 38.57048452], [ 71.51317802, 86.37179563]], Modified: trunk/numpy/lib/function_base.py =================================================================== --- trunk/numpy/lib/function_base.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/lib/function_base.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -471,7 +471,7 @@ Examples -------- - >>> average(range(1,11), weights=range(10,0,-1)) + >>> np.average(range(1,11), weights=range(10,0,-1)) 4.0 Raises @@ -893,7 +893,7 @@ Examples -------- - >>> a = array((0, 0, 0, 1, 2, 3, 2, 1, 0)) + >>> a = np.array((0, 0, 0, 1, 2, 3, 2, 1, 0)) >>> np.trim_zeros(a) array([1, 2, 3, 2, 1]) @@ -1069,7 +1069,7 @@ ... else: ... return a+b - >>> vfunc = vectorize(myfunc) + >>> vfunc = np.vectorize(myfunc) >>> vfunc([1, 2, 3, 4], 2) array([3, 4, 1, 2]) @@ -1486,29 +1486,28 @@ Examples -------- - >>> from numpy import median >>> a = np.array([[10, 7, 4], [3, 2, 1]]) >>> a array([[10, 7, 4], [ 3, 2, 1]]) - >>> median(a) + >>> np.median(a) array([ 6.5, 4.5, 2.5]) - >>> median(a, axis=None) + >>> np.median(a, axis=None) 3.5 - >>> median(a, axis=1) + >>> np.median(a, axis=1) array([ 7., 2.]) - >>> m = median(a) + >>> m = np.median(a) >>> out = np.zeros_like(m) - >>> median(a, out=m) + >>> np.median(a, out=m) array([ 6.5, 4.5, 2.5]) >>> m array([ 6.5, 4.5, 2.5]) >>> b = a.copy() - >>> median(b, axis=1, overwrite_input=True) + >>> np.median(b, axis=1, overwrite_input=True) array([ 7., 2.]) >>> assert not np.all(a==b) >>> b = a.copy() - >>> median(b, axis=None, overwrite_input=True) + >>> np.median(b, axis=None, overwrite_input=True) 3.5 >>> assert not np.all(a==b) """ @@ -1632,11 +1631,11 @@ ... [1,2,3], ... [6,7,8]] - >>> delete(arr, 1, 1) + >>> np.delete(arr, 1, 1) array([[3, 5], [1, 3], [6, 8]]) - >>> delete(arr, 1, 0) + >>> np.delete(arr, 1, 0) array([[3, 4, 5], [6, 7, 8]]) """ @@ -1732,11 +1731,11 @@ Examples -------- - >>> a = array([[1,2,3], - ... [4,5,6], - ... [7,8,9]]) + >>> a = np.array([[1,2,3], + ... [4,5,6], + ... [7,8,9]]) - >>> insert(a, [1,2], [[4],[5]], axis=0) + >>> np.insert(a, [1,2], [[4],[5]], axis=0) array([[1, 2, 3], [4, 4, 4], [4, 5, 6], Modified: trunk/numpy/lib/io.py =================================================================== --- trunk/numpy/lib/io.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/lib/io.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -344,9 +344,9 @@ Examples -------- - >>> savetxt('test.out', x, delimiter=',') # X is an array - >>> savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays - >>> savetxt('test.out', x, fmt='%1.4e') # use exponential notation + >>> np.savetxt('test.out', x, delimiter=',') # X is an array + >>> np.savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays + >>> np.savetxt('test.out', x, fmt='%1.4e') # use exponential notation Notes on fmt ------------ Modified: trunk/numpy/lib/polynomial.py =================================================================== --- trunk/numpy/lib/polynomial.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/lib/polynomial.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -52,8 +52,8 @@ Example: - >>> b = roots([1,3,1,5,6]) - >>> poly(b) + >>> b = np.roots([1,3,1,5,6]) + >>> np.poly(b) array([ 1., 3., 1., 5., 6.]) """ Modified: trunk/numpy/lib/scimath.py =================================================================== --- trunk/numpy/lib/scimath.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/lib/scimath.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -50,8 +50,8 @@ >>> a = np.array([1,2,3],np.short) - >>> ac = _tocomplex(a); ac - array([ 1.+0.j, 2.+0.j, 3.+0.j], dtype=complex64) + >>> ac = np.lib.scimath._tocomplex(a); ac + array([ 1.+0.j, 2.+0.j, 3.+0.j], dtype=np.complex64) >>> ac.dtype dtype('complex64') @@ -61,7 +61,7 @@ >>> b = np.array([1,2,3],np.double) - >>> bc = _tocomplex(b); bc + >>> bc = np.lib.scimath._tocomplex(b); bc array([ 1.+0.j, 2.+0.j, 3.+0.j]) >>> bc.dtype @@ -72,7 +72,7 @@ >>> c = np.array([1,2,3],np.csingle) - >>> cc = _tocomplex(c); cc + >>> cc = np.lib.scimath._tocomplex(c); cc array([ 1.+0.j, 2.+0.j, 3.+0.j], dtype=complex64) >>> c *= 2; c @@ -102,10 +102,10 @@ Examples -------- - >>> _fix_real_lt_zero([1,2]) + >>> np.lib.scimath._fix_real_lt_zero([1,2]) array([1, 2]) - >>> _fix_real_lt_zero([-1,2]) + >>> np.lib.scimath._fix_real_lt_zero([-1,2]) array([-1.+0.j, 2.+0.j]) """ x = asarray(x) @@ -128,10 +128,10 @@ Examples -------- - >>> _fix_int_lt_zero([1,2]) + >>> np.lib.scimath._fix_int_lt_zero([1,2]) array([1, 2]) - >>> _fix_int_lt_zero([-1,2]) + >>> np.lib.scimath._fix_int_lt_zero([-1,2]) array([-1., 2.]) """ x = asarray(x) @@ -154,10 +154,10 @@ Examples -------- - >>> _fix_real_abs_gt_1([0,1]) + >>> np.lib.scimath._fix_real_abs_gt_1([0,1]) array([0, 1]) - >>> _fix_real_abs_gt_1([0,2]) + >>> np.lib.scimath._fix_real_abs_gt_1([0,2]) array([ 0.+0.j, 2.+0.j]) """ x = asarray(x) @@ -180,17 +180,17 @@ -------- For real, non-negative inputs this works just like numpy.sqrt(): - >>> sqrt(1) + >>> np.lib.scimath.sqrt(1) 1.0 - >>> sqrt([1,4]) + >>> np.lib.scimath.sqrt([1,4]) array([ 1., 2.]) But it automatically handles negative inputs: - >>> sqrt(-1) + >>> np.lib.scimath.sqrt(-1) (0.0+1.0j) - >>> sqrt([-1,4]) + >>> np.lib.scimath.sqrt([-1,4]) array([ 0.+1.j, 2.+0.j]) """ x = _fix_real_lt_zero(x) @@ -213,14 +213,13 @@ Examples -------- >>> import math - - >>> log(math.exp(1)) + >>> np.lib.scimath.log(math.exp(1)) 1.0 Negative arguments are correctly handled (recall that for negative arguments, the identity exp(log(z))==z does not hold anymore): - >>> log(-math.exp(1)) == (1+1j*math.pi) + >>> np.lib.scimath.log(-math.exp(1)) == (1+1j*math.pi) True """ x = _fix_real_lt_zero(x) @@ -246,11 +245,11 @@ (We set the printing precision so the example can be auto-tested) >>> np.set_printoptions(precision=4) - >>> log10([10**1,10**2]) + >>> np.lib.scimath.log10([10**1,10**2]) array([ 1., 2.]) - >>> log10([-10**1,-10**2,10**2]) + >>> np.lib.scimath.log10([-10**1,-10**2,10**2]) array([ 1.+1.3644j, 2.+1.3644j, 2.+0.j ]) """ x = _fix_real_lt_zero(x) @@ -276,10 +275,10 @@ (We set the printing precision so the example can be auto-tested) >>> np.set_printoptions(precision=4) - >>> logn(2,[4,8]) + >>> np.lib.scimath.logn(2,[4,8]) array([ 2., 3.]) - >>> logn(2,[-4,-8,8]) + >>> np.lib.scimath.logn(2,[-4,-8,8]) array([ 2.+4.5324j, 3.+4.5324j, 3.+0.j ]) """ x = _fix_real_lt_zero(x) @@ -306,10 +305,10 @@ (We set the printing precision so the example can be auto-tested) >>> np.set_printoptions(precision=4) - >>> log2([4,8]) + >>> np.lib.scimath.log2([4,8]) array([ 2., 3.]) - >>> log2([-4,-8,8]) + >>> np.lib.scimath.log2([-4,-8,8]) array([ 2.+4.5324j, 3.+4.5324j, 3.+0.j ]) """ x = _fix_real_lt_zero(x) @@ -336,13 +335,13 @@ (We set the printing precision so the example can be auto-tested) >>> np.set_printoptions(precision=4) - >>> power([2,4],2) + >>> np.lib.scimath.power([2,4],2) array([ 4, 16]) - >>> power([2,4],-2) + >>> np.lib.scimath.power([2,4],-2) array([ 0.25 , 0.0625]) - >>> power([-2,4],2) + >>> np.lib.scimath.power([-2,4],2) array([ 4.+0.j, 16.+0.j]) """ x = _fix_real_lt_zero(x) @@ -368,10 +367,10 @@ -------- >>> np.set_printoptions(precision=4) - >>> arccos(1) + >>> np.lib.scimath.arccos(1) 0.0 - >>> arccos([1,2]) + >>> np.lib.scimath.arccos([1,2]) array([ 0.-0.j , 0.+1.317j]) """ x = _fix_real_abs_gt_1(x) @@ -397,10 +396,10 @@ (We set the printing precision so the example can be auto-tested) >>> np.set_printoptions(precision=4) - >>> arcsin(0) + >>> np.lib.scimath.arcsin(0) 0.0 - >>> arcsin([0,1]) + >>> np.lib.scimath.arcsin([0,1]) array([ 0. , 1.5708]) """ x = _fix_real_abs_gt_1(x) @@ -426,10 +425,10 @@ (We set the printing precision so the example can be auto-tested) >>> np.set_printoptions(precision=4) - >>> arctanh(0) + >>> np.lib.scimath.arctanh(0) 0.0 - >>> arctanh([0,2]) + >>> np.lib.scimath.arctanh([0,2]) array([ 0.0000+0.j , 0.5493-1.5708j]) """ x = _fix_real_abs_gt_1(x) Modified: trunk/numpy/lib/shape_base.py =================================================================== --- trunk/numpy/lib/shape_base.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/lib/shape_base.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -192,13 +192,13 @@ tup -- sequence of arrays. All arrays must have the same shape. Examples: - >>> a = array((1,2,3)) - >>> b = array((2,3,4)) + >>> a = np.array((1,2,3)) + >>> b = np.array((2,3,4)) >>> np.vstack((a,b)) array([[1, 2, 3], [2, 3, 4]]) - >>> a = array([[1],[2],[3]]) - >>> b = array([[2],[3],[4]]) + >>> a = np.array([[1],[2],[3]]) + >>> b = np.array([[2],[3],[4]]) >>> np.vstack((a,b)) array([[1], [2], @@ -222,14 +222,13 @@ tup -- sequence of arrays. All arrays must have the same shape. Examples: - >>> import numpy - >>> a = array((1,2,3)) - >>> b = array((2,3,4)) - >>> numpy.hstack((a,b)) + >>> a = np.array((1,2,3)) + >>> b = np.array((2,3,4)) + >>> np.hstack((a,b)) array([1, 2, 3, 2, 3, 4]) - >>> a = array([[1],[2],[3]]) - >>> b = array([[2],[3],[4]]) - >>> numpy.hstack((a,b)) + >>> a = np.array([[1],[2],[3]]) + >>> b = np.array([[2],[3],[4]]) + >>> np.hstack((a,b)) array([[1, 2], [2, 3], [3, 4]]) @@ -253,10 +252,9 @@ tup -- sequence of 1D or 2D arrays. All arrays must have the same first dimension. Examples: - >>> import numpy - >>> a = array((1,2,3)) - >>> b = array((2,3,4)) - >>> numpy.column_stack((a,b)) + >>> a = np.array((1,2,3)) + >>> b = np.array((2,3,4)) + >>> np.column_stack((a,b)) array([[1, 2], [2, 3], [3, 4]]) @@ -283,16 +281,15 @@ tup -- sequence of arrays. All arrays must have the same shape. Examples: - >>> import numpy - >>> a = array((1,2,3)) - >>> b = array((2,3,4)) - >>> numpy.dstack((a,b)) + >>> a = np.array((1,2,3)) + >>> b = np.array((2,3,4)) + >>> np.dstack((a,b)) array([[[1, 2], [2, 3], [3, 4]]]) - >>> a = array([[1],[2],[3]]) - >>> b = array([[2],[3],[4]]) - >>> numpy.dstack((a,b)) + >>> a = np.array([[1],[2],[3]]) + >>> b = np.array([[2],[3],[4]]) + >>> np.dstack((a,b)) array([[[1, 2]], [[2, 3]], @@ -432,12 +429,11 @@ Related: hstack, split, array_split, vsplit, dsplit. Examples: - >>> import numpy - >>> a= array((1,2,3,4)) - >>> numpy.hsplit(a,2) + >>> a= np.array((1,2,3,4)) + >>> np.hsplit(a,2) [array([1, 2]), array([3, 4])] - >>> a = array([[1,2,3,4],[1,2,3,4]]) - >>> hsplit(a,2) + >>> a = np.array([[1,2,3,4],[1,2,3,4]]) + >>> np.hsplit(a,2) [array([[1, 2], [1, 2]]), array([[3, 4], [3, 4]])] @@ -482,9 +478,9 @@ vstack, split, array_split, hsplit, dsplit. Examples: import numpy - >>> a = array([[1,2,3,4], - ... [1,2,3,4]]) - >>> numpy.vsplit(a,2) + >>> a = np.array([[1,2,3,4], + ... [1,2,3,4]]) + >>> np.vsplit(a,2) [array([[1, 2, 3, 4]]), array([[1, 2, 3, 4]])] """ @@ -519,8 +515,8 @@ Related: dstack, split, array_split, hsplit, vsplit. Examples: - >>> a = array([[[1,2,3,4],[1,2,3,4]]]) - >>> dsplit(a,2) + >>> a = np.array([[[1,2,3,4],[1,2,3,4]]]) + >>> np.dsplit(a,2) [array([[[1, 2], [1, 2]]]), array([[[3, 4], [3, 4]]])] @@ -596,15 +592,15 @@ Examples: - >>> a = array([0,1,2]) - >>> tile(a,2) + >>> a = np.array([0,1,2]) + >>> np.tile(a,2) array([0, 1, 2, 0, 1, 2]) - >>> tile(a,(1,2)) + >>> np.tile(a,(1,2)) array([[0, 1, 2, 0, 1, 2]]) - >>> tile(a,(2,2)) + >>> np.tile(a,(2,2)) array([[0, 1, 2, 0, 1, 2], [0, 1, 2, 0, 1, 2]]) - >>> tile(a,(2,1,2)) + >>> np.tile(a,(2,1,2)) array([[[0, 1, 2, 0, 1, 2]], [[0, 1, 2, 0, 1, 2]]]) Modified: trunk/numpy/lib/twodim_base.py =================================================================== --- trunk/numpy/lib/twodim_base.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/lib/twodim_base.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -88,13 +88,13 @@ Examples -------- - >>> diagflat([[1,2],[3,4]]]) + >>> np.diagflat([[1,2],[3,4]]) array([[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]) - >>> diagflat([1,2], 1) + >>> np.diagflat([1,2], 1) array([[0, 1, 0], [0, 0, 2], [0, 0, 0]]) @@ -180,8 +180,8 @@ - `xedges, yedges` : Arrays defining the bin edges. Example: - >>> x = random.randn(100,2) - >>> hist2d, xedges, yedges = histogram2d(x, bins = (6, 7)) + >>> x = np.random.randn(100,2) + >>> hist2d, xedges, yedges = np.lib.histogram2d(x, bins = (6, 7)) :SeeAlso: histogramdd """ Modified: trunk/numpy/linalg/linalg.py =================================================================== --- trunk/numpy/linalg/linalg.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/linalg/linalg.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -163,18 +163,17 @@ Examples -------- - >>> from numpy import * - >>> a = eye(2*3*4) + >>> a = np.eye(2*3*4) >>> a.shape = (2*3,4, 2,3,4) - >>> b = random.randn(2*3,4) - >>> x = linalg.tensorsolve(a, b) + >>> b = np.random.randn(2*3,4) + >>> x = np.linalg.tensorsolve(a, b) >>> x.shape (2, 3, 4) - >>> allclose(tensordot(a, x, axes=3), b) + >>> np.allclose(np.tensordot(a, x, axes=3), b) True """ - a = asarray(a) + a,wrap = _makearray(a) b = asarray(b) an = a.ndim @@ -266,23 +265,22 @@ Examples -------- - >>> from numpy import * - >>> a = eye(4*6) + >>> a = np.eye(4*6) >>> a.shape = (4,6,8,3) - >>> ainv = linalg.tensorinv(a, ind=2) + >>> ainv = np.linalg.tensorinv(a, ind=2) >>> ainv.shape (8, 3, 4, 6) - >>> b = random.randn(4,6) - >>> allclose(tensordot(ainv, b), linalg.tensorsolve(a, b)) + >>> b = np.random.randn(4,6) + >>> np.allclose(np.tensordot(ainv, b), np.linalg.tensorsolve(a, b)) True - >>> a = eye(4*6) + >>> a = np.eye(4*6) >>> a.shape = (24,8,3) - >>> ainv = linalg.tensorinv(a, ind=1) + >>> ainv = np.linalg.tensorinv(a, ind=1) >>> ainv.shape (8, 3, 24) - >>> b = random.randn(24) - >>> allclose(tensordot(ainv, b, 1), linalg.tensorsolve(a, b)) + >>> b = np.random.randn(24) + >>> np.allclose(np.tensordot(ainv, b, 1), np.linalg.tensorsolve(a, b)) True """ a = asarray(a) @@ -318,12 +316,11 @@ Examples -------- - >>> from numpy import array, inv, dot - >>> a = array([[1., 2.], [3., 4.]]) - >>> inv(a) + >>> a = np.array([[1., 2.], [3., 4.]]) + >>> np.linalg.inv(a) array([[-2. , 1. ], [ 1.5, -0.5]]) - >>> dot(a, inv(a)) + >>> np.dot(a, np.linalg.inv(a)) array([[ 1., 0.], [ 0., 1.]]) @@ -360,7 +357,7 @@ >>> L array([[ 1.+0.j, 0.+0.j], [ 0.+2.j, 1.+0.j]]) - >>> dot(L, L.T.conj()) + >>> np.dot(L, L.T.conj()) array([[ 1.+0.j, 0.-2.j], [ 0.+2.j, 5.+0.j]]) @@ -427,16 +424,15 @@ Examples -------- - >>> from numpy import * - >>> a = random.randn(9, 6) - >>> q, r = linalg.qr(a) - >>> allclose(a, dot(q, r)) + >>> a = np.random.randn(9, 6) + >>> q, r = np.linalg.qr(a) + >>> np.allclose(a, np.dot(q, r)) True - >>> r2 = linalg.qr(a, mode='r') - >>> r3 = linalg.qr(a, mode='economic') - >>> allclose(r, r2) + >>> r2 = np.linalg.qr(a, mode='r') + >>> r3 = np.linalg.qr(a, mode='economic') + >>> np.allclose(r, r2) True - >>> allclose(r, triu(r3[:6,:6], k=0)) + >>> np.allclose(r, np.triu(r3[:6,:6], k=0)) True """ @@ -909,20 +905,20 @@ Examples -------- - >>> a = random.randn(9, 6) + 1j*random.randn(9, 6) - >>> U, s, Vh = linalg.svd(a) + >>> a = np.random.randn(9, 6) + 1j*np.random.randn(9, 6) + >>> U, s, Vh = np.linalg.svd(a) >>> U.shape, Vh.shape, s.shape ((9, 9), (6, 6), (6,)) - >>> U, s, Vh = linalg.svd(a, full_matrices=False) + >>> U, s, Vh = np.linalg.svd(a, full_matrices=False) >>> U.shape, Vh.shape, s.shape ((9, 6), (6, 6), (6,)) - >>> S = diag(s) - >>> allclose(a, dot(U, dot(S, Vh))) + >>> S = np.diag(s) + >>> np.allclose(a, np.dot(U, np.dot(S, Vh))) True - >>> s2 = linalg.svd(a, compute_uv=False) - >>> allclose(s, s2) + >>> s2 = np.linalg.svd(a, compute_uv=False) + >>> np.allclose(s, s2) True """ a, wrap = _makearray(a) @@ -1048,12 +1044,11 @@ Examples -------- - >>> from numpy import * - >>> a = random.randn(9, 6) - >>> B = linalg.pinv(a) - >>> allclose(a, dot(a, dot(B, a))) + >>> a = np.random.randn(9, 6) + >>> B = np.linalg.pinv(a) + >>> np.allclose(a, np.dot(a, np.dot(B, a))) True - >>> allclose(B, dot(B, dot(a, B))) + >>> np.allclose(B, np.dot(B, np.dot(a, B))) True """ Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/ma/core.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -1694,7 +1694,7 @@ Examples -------- - >>> x = array([1,2,3,4,5], mask=[0,0,1,0,1], fill_value=-999) + >>> x = np.ma.array([1,2,3,4,5], mask=[0,0,1,0,1], fill_value=-999) >>> x.filled() array([1,2,-999,4,-999]) >>> type(x.filled()) @@ -2116,10 +2116,10 @@ Example ------- - >>> array([1,2,3]).all() + >>> np.ma.array([1,2,3]).all() True - >>> a = array([1,2,3], mask=True) - >>> (a.all() is masked) + >>> a = np.ma.array([1,2,3], mask=True) + >>> (a.all() is np.ma.masked) True """ @@ -2293,7 +2293,7 @@ Example ------- - >>> print array(arange(10),mask=[0,0,0,1,1,1,0,0,0,0]).cumsum() + >>> print np.ma.array(np.arange(10), mask=[0,0,0,1,1,1,0,0,0,0]).cumsum() [0 1 3 -- -- -- 9 16 24 33] @@ -2348,13 +2348,13 @@ Examples -------- - >>> prod([1.,2.]) + >>> np.prod([1.,2.]) 2.0 - >>> prod([1.,2.], dtype=int32) + >>> np.prod([1.,2.], dtype=np.int32) 2 - >>> prod([[1.,2.],[3.,4.]]) + >>> np.prod([[1.,2.],[3.,4.]]) 24.0 - >>> prod([[1.,2.],[3.,4.]], axis=1) + >>> np.prod([[1.,2.],[3.,4.]], axis=1) array([ 2., 12.]) Notes @@ -2755,7 +2755,7 @@ Examples -------- - >>> a = arange(6).reshape(2,3) + >>> a = np.arange(6).reshape(2,3) >>> a.argmax() 5 >>> a.argmax(0) Modified: trunk/numpy/ma/extras.py =================================================================== --- trunk/numpy/ma/extras.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/ma/extras.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -716,7 +716,7 @@ """Translate slice objects to concatenation along the first axis. For example: - >>> mr_[array([1,2,3]), 0, 0, array([4,5,6])] + >>> np.ma.mr_[np.ma.array([1,2,3]), 0, 0, np.ma.array([4,5,6])] array([1, 2, 3, 0, 0, 4, 5, 6]) """ Modified: trunk/numpy/testing/decorators.py =================================================================== --- trunk/numpy/testing/decorators.py 2008-07-05 01:17:03 UTC (rev 5350) +++ trunk/numpy/testing/decorators.py 2008-07-05 14:26:16 UTC (rev 5351) @@ -30,6 +30,7 @@ If True specifies this is a test, not a test otherwise e.g + >>> from numpy.testing.decorators import setastest >>> @setastest(False) ... def func_with_test_in_name(arg1, arg2): pass ... From numpy-svn at scipy.org Sat Jul 5 10:32:46 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 5 Jul 2008 09:32:46 -0500 (CDT) Subject: [Numpy-svn] r5352 - trunk/numpy/lib Message-ID: <20080705143246.9FEEE39C647@scipy.org> Author: alan.mcintyre Date: 2008-07-05 09:32:42 -0500 (Sat, 05 Jul 2008) New Revision: 5352 Removed: trunk/numpy/lib/convdtype.py Log: Removed convdtype.py as discussed on numpy-discussion list (code was intended for the Numeric to numpy transition, but was never used). Deleted: trunk/numpy/lib/convdtype.py =================================================================== --- trunk/numpy/lib/convdtype.py 2008-07-05 14:26:16 UTC (rev 5351) +++ trunk/numpy/lib/convdtype.py 2008-07-05 14:32:42 UTC (rev 5352) @@ -1,65 +0,0 @@ -from tokenize import generate_tokens -import token -import sys -def insert(s1, s2, posn): - """insert s1 into s2 at positions posn - - >>> insert("XX", "abcdef", [2, 4]) - 'abXXcdXXef' - """ - pieces = [] - start = 0 - for end in posn + [len(s2)]: - pieces.append(s2[start:end]) - start = end - return s1.join(pieces) - -def insert_dtype(readline, output=None): - """ - >>> from StringIO import StringIO - >>> src = "zeros((2,3), dtype=float); zeros((2,3));" - >>> insert_dtype(StringIO(src).readline) - zeros((2,3), dtype=float); zeros((2,3), dtype=int); - """ - if output is None: - output = sys.stdout - tokens = generate_tokens(readline) - flag = 0 - parens = 0 - argno = 0 - posn = [] - nodtype = True - prevtok = None - kwarg = 0 - for (tok_type, tok, (srow, scol), (erow, ecol), line) in tokens: - if not flag and tok_type == token.NAME and tok in ('zeros', 'ones', 'empty'): - flag = 1 - else: - if tok == '(': - parens += 1 - elif tok == ')': - parens -= 1 - if parens == 0: - if nodtype and argno < 1: - posn.append(scol) - argno = 0 - flag = 0 - nodtype = True - argno = 0 - elif tok == '=': - kwarg = 1 - if prevtok == 'dtype': - nodtype = False - elif tok == ',': - argno += (parens == 1) - if len(line) == ecol: - output.write(insert(', dtype=int', line, posn)) - posn = [] - prevtok = tok - -def _test(): - import doctest - doctest.testmod() - -if __name__ == "__main__": - _test() From numpy-svn at scipy.org Sat Jul 5 10:50:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 5 Jul 2008 09:50:30 -0500 (CDT) Subject: [Numpy-svn] r5353 - in trunk/numpy: distutils/tests/f2py_ext/tests distutils/tests/f2py_f90_ext/tests distutils/tests/gen_ext/tests distutils/tests/pyrex_ext/tests distutils/tests/swig_ext/tests f2py/tests/array_from_pyobj/tests Message-ID: <20080705145030.2E6BA39C3D8@scipy.org> Author: alan.mcintyre Date: 2008-07-05 09:50:19 -0500 (Sat, 05 Jul 2008) New Revision: 5353 Modified: trunk/numpy/distutils/tests/f2py_ext/tests/test_fib2.py trunk/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py trunk/numpy/distutils/tests/gen_ext/tests/test_fib3.py trunk/numpy/distutils/tests/pyrex_ext/tests/test_primes.py trunk/numpy/distutils/tests/swig_ext/tests/test_example.py trunk/numpy/distutils/tests/swig_ext/tests/test_example2.py trunk/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py Log: Remove uses of set_package_path, set_local_path, restore_path, and associated sys.path manipulations. Modified: trunk/numpy/distutils/tests/f2py_ext/tests/test_fib2.py =================================================================== --- trunk/numpy/distutils/tests/f2py_ext/tests/test_fib2.py 2008-07-05 14:32:42 UTC (rev 5352) +++ trunk/numpy/distutils/tests/f2py_ext/tests/test_fib2.py 2008-07-05 14:50:19 UTC (rev 5353) @@ -1,8 +1,6 @@ import sys from numpy.testing import * -set_package_path() from f2py_ext import fib2 -del sys.path[0] class TestFib2(TestCase): Modified: trunk/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py =================================================================== --- trunk/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py 2008-07-05 14:32:42 UTC (rev 5352) +++ trunk/numpy/distutils/tests/f2py_f90_ext/tests/test_foo.py 2008-07-05 14:50:19 UTC (rev 5353) @@ -1,11 +1,8 @@ import sys from numpy.testing import * -set_package_path() from f2py_f90_ext import foo -del sys.path[0] class TestFoo(TestCase): - def test_foo_free(self): assert_equal(foo.foo_free.bar13(),13) Modified: trunk/numpy/distutils/tests/gen_ext/tests/test_fib3.py =================================================================== --- trunk/numpy/distutils/tests/gen_ext/tests/test_fib3.py 2008-07-05 14:32:42 UTC (rev 5352) +++ trunk/numpy/distutils/tests/gen_ext/tests/test_fib3.py 2008-07-05 14:50:19 UTC (rev 5353) @@ -1,11 +1,8 @@ import sys from numpy.testing import * -set_package_path() from gen_ext import fib3 -del sys.path[0] class TestFib3(TestCase): - def test_fib(self): assert_array_equal(fib3.fib(6),[0,1,1,2,3,5]) Modified: trunk/numpy/distutils/tests/pyrex_ext/tests/test_primes.py =================================================================== --- trunk/numpy/distutils/tests/pyrex_ext/tests/test_primes.py 2008-07-05 14:32:42 UTC (rev 5352) +++ trunk/numpy/distutils/tests/pyrex_ext/tests/test_primes.py 2008-07-05 14:50:19 UTC (rev 5353) @@ -1,13 +1,12 @@ import sys from numpy.testing import * - -set_package_path() from pyrex_ext.primes import primes -restore_path() class TestPrimes(TestCase): def test_simple(self, level=1): l = primes(10) assert_equal(l, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) + + if __name__ == "__main__": run_module_suite() Modified: trunk/numpy/distutils/tests/swig_ext/tests/test_example.py =================================================================== --- trunk/numpy/distutils/tests/swig_ext/tests/test_example.py 2008-07-05 14:32:42 UTC (rev 5352) +++ trunk/numpy/distutils/tests/swig_ext/tests/test_example.py 2008-07-05 14:50:19 UTC (rev 5353) @@ -1,11 +1,8 @@ import sys from numpy.testing import * -set_package_path() from swig_ext import example -restore_path() class TestExample(TestCase): - def test_fact(self): assert_equal(example.fact(10),3628800) @@ -14,5 +11,6 @@ example.cvar.My_variable = 5 assert_equal(example.cvar.My_variable,5.0) + if __name__ == "__main__": run_module_suite() Modified: trunk/numpy/distutils/tests/swig_ext/tests/test_example2.py =================================================================== --- trunk/numpy/distutils/tests/swig_ext/tests/test_example2.py 2008-07-05 14:32:42 UTC (rev 5352) +++ trunk/numpy/distutils/tests/swig_ext/tests/test_example2.py 2008-07-05 14:50:19 UTC (rev 5353) @@ -1,11 +1,8 @@ import sys from numpy.testing import * -set_package_path() from swig_ext import example2 -restore_path() class TestExample2(TestCase): - def test_zoo(self): z = example2.Zoo() z.shut_up('Tiger') Modified: trunk/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py =================================================================== --- trunk/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py 2008-07-05 14:32:42 UTC (rev 5352) +++ trunk/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py 2008-07-05 14:50:19 UTC (rev 5353) @@ -5,10 +5,7 @@ from numpy.testing import * from numpy import array, alltrue, ndarray, asarray, can_cast,zeros, dtype from numpy.core.multiarray import typeinfo - -set_package_path() from array_from_pyobj import wrap -restore_path() def flags_info(arr): flags = wrap.array_attrs(arr)[6] From numpy-svn at scipy.org Sun Jul 6 01:03:48 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 6 Jul 2008 00:03:48 -0500 (CDT) Subject: [Numpy-svn] r5354 - trunk/numpy/f2py Message-ID: <20080706050348.DEF3139C3D5@scipy.org> Author: cdavid Date: 2008-07-06 00:03:44 -0500 (Sun, 06 Jul 2008) New Revision: 5354 Modified: trunk/numpy/f2py/setupscons.py Log: Remove f2py.lib from setupscons.py Modified: trunk/numpy/f2py/setupscons.py =================================================================== --- trunk/numpy/f2py/setupscons.py 2008-07-05 14:50:19 UTC (rev 5353) +++ trunk/numpy/f2py/setupscons.py 2008-07-06 05:03:44 UTC (rev 5354) @@ -30,8 +30,6 @@ def configuration(parent_package='',top_path=None): config = Configuration('f2py', parent_package, top_path) - config.add_subpackage('lib') - config.add_data_dir('docs') config.add_data_files('src/fortranobject.c', From numpy-svn at scipy.org Sun Jul 6 01:22:21 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 6 Jul 2008 00:22:21 -0500 (CDT) Subject: [Numpy-svn] r5355 - trunk/numpy/core Message-ID: <20080706052221.717DC39C3D5@scipy.org> Author: cdavid Date: 2008-07-06 00:22:17 -0500 (Sun, 06 Jul 2008) New Revision: 5355 Modified: trunk/numpy/core/SConscript Log: Prepend bootstrapping include path to avoid problem with debian numpy. Modified: trunk/numpy/core/SConscript =================================================================== --- trunk/numpy/core/SConscript 2008-07-06 05:03:44 UTC (rev 5354) +++ trunk/numpy/core/SConscript 2008-07-06 05:22:17 UTC (rev 5355) @@ -1,4 +1,4 @@ -# Last Change: Thu Jun 12 04:00 PM 2008 J +# Last Change: Sun Jul 06 01:00 PM 2008 J # vim:syntax=python import os import sys @@ -234,7 +234,7 @@ ufunc_api = env.GenerateUfuncApi('ufunc_api', pjoin('code_generators', 'ufunc_api_order.txt')) -env.Append(CPPPATH = ['include', '.']) +env.Prepend(CPPPATH = ['include', '.']) #----------------- # Build multiarray From numpy-svn at scipy.org Sun Jul 6 13:16:16 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 6 Jul 2008 12:16:16 -0500 (CDT) Subject: [Numpy-svn] r5356 - branches/1.1.x/numpy/core/src Message-ID: <20080706171616.93E2339C743@scipy.org> Author: charris Date: 2008-07-06 12:16:14 -0500 (Sun, 06 Jul 2008) New Revision: 5356 Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src Log: Fix c++ style comment. Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src =================================================================== --- branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-06 05:22:17 UTC (rev 5355) +++ branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-06 17:16:14 UTC (rev 5356) @@ -1515,7 +1515,7 @@ n=dimensions[0]; for(i=0; i Author: rkern Date: 2008-07-07 11:47:18 -0500 (Mon, 07 Jul 2008) New Revision: 5357 Modified: trunk/numpy/core/numeric.py trunk/numpy/core/tests/test_numeric.py Log: Return actual bools instead of 0 or 1. Modified: trunk/numpy/core/numeric.py =================================================================== --- trunk/numpy/core/numeric.py 2008-07-06 17:16:14 UTC (rev 5356) +++ trunk/numpy/core/numeric.py 2008-07-07 16:47:18 UTC (rev 5357) @@ -137,7 +137,7 @@ def asanyarray(a, dtype=None, order=None): """Returns a as an array, but will pass subclasses through. """ - return array(a, dtype, copy=False, order=order, subok=1) + return array(a, dtype, copy=False, order=order, subok=True) def ascontiguousarray(a, dtype=None): """Return 'a' as an array contiguous in memory (C order). @@ -182,9 +182,9 @@ return asanyarray(a, dtype=dtype) if 'ENSUREARRAY' in requirements or 'E' in requirements: - subok = 0 + subok = False else: - subok = 1 + subok = True arr = array(a, dtype=dtype, copy=False, subok=subok) @@ -342,12 +342,12 @@ nda = len(a.shape) bs = b.shape ndb = len(b.shape) - equal = 1 - if (na != nb): equal = 0 + equal = True + if (na != nb): equal = False else: for k in xrange(na): if as_[axes_a[k]] != bs[axes_b[k]]: - equal = 0 + equal = False break if axes_a[k] < 0: axes_a[k] += nda @@ -391,10 +391,10 @@ a = asanyarray(a) if axis is None: n = a.size - reshape=1 + reshape = True else: n = a.shape[axis] - reshape=0 + reshape = False shift %= n indexes = concatenate((arange(n-shift,n),arange(n-shift))) res = a.take(indexes, axis) @@ -728,10 +728,10 @@ try: a1, a2 = asarray(a1), asarray(a2) except: - return 0 + return False if a1.shape != a2.shape: - return 0 - return logical_and.reduce(equal(a1,a2).ravel()) + return False + return bool(logical_and.reduce(equal(a1,a2).ravel())) def array_equiv(a1, a2): """Returns True if a1 and a2 are shape consistent @@ -741,11 +741,11 @@ try: a1, a2 = asarray(a1), asarray(a2) except: - return 0 + return False try: - return logical_and.reduce(equal(a1,a2).ravel()) + return bool(logical_and.reduce(equal(a1,a2).ravel())) except ValueError: - return 0 + return False _errdict = {"ignore":ERR_IGNORE, Modified: trunk/numpy/core/tests/test_numeric.py =================================================================== --- trunk/numpy/core/tests/test_numeric.py 2008-07-06 17:16:14 UTC (rev 5356) +++ trunk/numpy/core/tests/test_numeric.py 2008-07-07 16:47:18 UTC (rev 5357) @@ -256,6 +256,52 @@ assert_equal(binary_repr(-1, width=8), '11111111') +class TestArrayComparisons(TestCase): + def test_array_equal(self): + res = array_equal(array([1,2]), array([1,2])) + assert res + assert type(res) is bool + res = array_equal(array([1,2]), array([1,2,3])) + assert not res + assert type(res) is bool + res = array_equal(array([1,2]), array([3,4])) + assert not res + assert type(res) is bool + res = array_equal(array([1,2]), array([1,3])) + assert not res + assert type(res) is bool + + def test_array_equiv(self): + res = array_equiv(array([1,2]), array([1,2])) + assert res + assert type(res) is bool + res = array_equiv(array([1,2]), array([1,2,3])) + assert not res + assert type(res) is bool + res = array_equiv(array([1,2]), array([3,4])) + assert not res + assert type(res) is bool + res = array_equiv(array([1,2]), array([1,3])) + assert not res + assert type(res) is bool + + res = array_equiv(array([1,1]), array([1])) + assert res + assert type(res) is bool + res = array_equiv(array([1,1]), array([[1],[1]])) + assert res + assert type(res) is bool + res = array_equiv(array([1,2]), array([2])) + assert not res + assert type(res) is bool + res = array_equiv(array([1,2]), array([[1],[2]])) + assert not res + assert type(res) is bool + res = array_equiv(array([1,2]), array([[1,2,3],[4,5,6],[7,8,9]])) + assert not res + assert type(res) is bool + + def assert_array_strict_equal(x, y): assert_array_equal(x, y) # Check flags From numpy-svn at scipy.org Tue Jul 8 03:29:35 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 8 Jul 2008 02:29:35 -0500 (CDT) Subject: [Numpy-svn] r5358 - trunk/numpy/core/tests Message-ID: <20080708072935.B780E39C140@scipy.org> Author: alan.mcintyre Date: 2008-07-08 02:29:23 -0500 (Tue, 08 Jul 2008) New Revision: 5358 Modified: trunk/numpy/core/tests/test_records.py Log: Renamed check_recarray_from_repr to test_recarray_from_repr so it can be picked up by nose. Modified: trunk/numpy/core/tests/test_records.py =================================================================== --- trunk/numpy/core/tests/test_records.py 2008-07-07 16:47:18 UTC (rev 5357) +++ trunk/numpy/core/tests/test_records.py 2008-07-08 07:29:23 UTC (rev 5358) @@ -52,7 +52,7 @@ assert (mine.data1[i] == 0.0) assert (mine.data2[i] == 0.0) - def check_recarray_from_repr(self): + def test_recarray_from_repr(self): x = np.rec.array([ (1, 2)],dtype=[('a', np.int8), ('b', np.int8)]) y = eval("np." + repr(x)) assert isinstance(y, np.recarray) From numpy-svn at scipy.org Tue Jul 8 03:49:43 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 8 Jul 2008 02:49:43 -0500 (CDT) Subject: [Numpy-svn] r5359 - trunk/numpy/doc Message-ID: <20080708074943.0DCDA39C071@scipy.org> Author: stefan Date: 2008-07-08 02:49:25 -0500 (Tue, 08 Jul 2008) New Revision: 5359 Added: trunk/numpy/doc/EXAMPLE_DOCSTRING.txt Log: Example of real docstring. Added: trunk/numpy/doc/EXAMPLE_DOCSTRING.txt =================================================================== --- trunk/numpy/doc/EXAMPLE_DOCSTRING.txt 2008-07-08 07:29:23 UTC (rev 5358) +++ trunk/numpy/doc/EXAMPLE_DOCSTRING.txt 2008-07-08 07:49:25 UTC (rev 5359) @@ -0,0 +1,103 @@ +.. Here follows an example docstring for a C-function. Note that the + signature is given. This is done only for functions written is C, + since Python cannot find their signature by inspection. For all + other functions, start with the one line description. + + +multivariate_normal(mean, cov[, shape]) + +Draw samples from a multivariate normal distribution. + +The multivariate normal, multinormal or Gaussian distribution is a +generalisation of the one-dimensional normal distribution to higher +dimensions. + +Such a distribution is specified by its mean and covariance matrix, +which are analogous to the mean (average or "centre") and variance +(standard deviation squared or "width") of the one-dimensional normal +distribution. + +Parameters +---------- +mean : (N,) ndarray + Mean of the N-dimensional distribution. +cov : (N,N) ndarray + Covariance matrix of the distribution. +shape : tuple of ints, optional + Given a shape of, for example, (m,n,k), m*n*k samples are + generated, and packed in an m-by-n-by-k arrangement. Because each + sample is N-dimensional, the output shape is (m,n,k,N). If no + shape is specified, a single sample is returned. + +Returns +------- +out : ndarray + The drawn samples, arranged according to `shape`. If the + shape given is (m,n,...), then the shape of `out` is is + (m,n,...,N). + + In other words, each entry ``out[i,j,...,:]`` is an N-dimensional + value drawn from the distribution. + +See Also +-------- +normal +scipy.stats.distributions.norm : Provides random variates, as well as + probability density function, cumulative + density function, etc. + +Notes +----- +The mean is a coordinate in N-dimensional space, which represents the +location where samples are most likely to be generated. This is +analogous to the peak of the bell curve for the one-dimensional or +univariate normal distribution. + +Covariance indicates the level to which two variables vary together. +From the multivariate normal distribution, we draw N-dimensional +samples, :math:`X = [x_1, x_2, ... x_N]`. The covariance matrix +element :math:`C_ij` is the covariance of :math:`x_i` and :math:`x_j`. +The element :math:`C_ii` is the variance of :math:`x_i` (i.e. its +"spread"). + +Instead of specifying the full covariance matrix, popular +approximations include: + + - Spherical covariance (`cov` is a multiple of the identity matrix) + - Diagonal covariance (`cov` has non-negative elements, and only on + the diagonal) + +This geometrical property can be seen in two dimensions by plotting +generated data-points: + +>>> mean = [0,0] +>>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis + +>>> x,y = numpy.multivariate_normal(mean,cov,5000).T +>>> pyplot.plot(x,y,'x'); pyplot.axis('equal'); pyplot.show() + +Note that the covariance matrix must be non-negative definite. + +References +---------- +.. [1] A. Papoulis, "Probability, Random Variables, and Stochastic + Processes," 3rd ed., McGraw-Hill Companies, 1991 +.. [2] R.O. Duda, P.E. Hart, and D.G. Stork, "Pattern Classification," + 2nd ed., Wiley, 2001. + +Examples +-------- +>>> mean = (1,2) +>>> cov = [[1,0],[1,0]] +>>> x = multivariate_normal(mean,cov,(3,3)) +>>> x.shape +(3, 3, 2) + +The following is probably true, given that 0.6 is roughly twice the +standard deviation: + +>>> print list( (x[0,0,:] - mean) < 0.6 ) +[True, True] + +.. index: + :refguide: random:distributions From numpy-svn at scipy.org Tue Jul 8 04:25:03 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 8 Jul 2008 03:25:03 -0500 (CDT) Subject: [Numpy-svn] r5360 - in trunk/numpy/lib: . tests Message-ID: <20080708082503.C023739C2F9@scipy.org> Author: stefan Date: 2008-07-08 03:24:37 -0500 (Tue, 08 Jul 2008) New Revision: 5360 Modified: trunk/numpy/lib/function_base.py trunk/numpy/lib/tests/test_function_base.py Log: Piecewise should not expose raw memory. Closes #798. Modified: trunk/numpy/lib/function_base.py =================================================================== --- trunk/numpy/lib/function_base.py 2008-07-08 07:49:25 UTC (rev 5359) +++ trunk/numpy/lib/function_base.py 2008-07-08 08:24:37 UTC (rev 5360) @@ -563,8 +563,11 @@ """ x = asanyarray(x) n2 = len(funclist) - if not isinstance(condlist, type([])): + if isscalar(condlist) or \ + not (isinstance(condlist[0], list) or + isinstance(condlist[0], ndarray)): condlist = [condlist] + condlist = [asarray(c, dtype=bool) for c in condlist] n = len(condlist) if n == n2-1: # compute the "otherwise" condition. totlist = condlist[0] @@ -573,10 +576,11 @@ condlist.append(~totlist) n += 1 if (n != n2): - raise ValueError, "function list and condition list must be the same" + raise ValueError, "function list and condition list " \ + "must be the same" zerod = False - # This is a hack to work around problems with NumPy's - # handling of 0-d arrays and boolean indexing with + # This is a hack to work around problems with NumPy's + # handling of 0-d arrays and boolean indexing with # numpy.bool_ scalars if x.ndim == 0: x = x[None] @@ -589,7 +593,8 @@ condition = condlist[k] newcondlist.append(condition) condlist = newcondlist - y = empty(x.shape, x.dtype) + + y = zeros(x.shape, x.dtype) for k in range(n): item = funclist[k] if not callable(item): @@ -1090,7 +1095,7 @@ self.__doc__ = pyfunc.__doc__ else: self.__doc__ = doc - if isinstance(otypes, types.StringType): + if isinstance(otypes, str): self.otypes = otypes for char in self.otypes: if char not in typecodes['All']: @@ -1121,7 +1126,7 @@ for arg in args: newargs.append(asarray(arg).flat[0]) theout = self.thefunc(*newargs) - if isinstance(theout, types.TupleType): + if isinstance(theout, tuple): self.nout = len(theout) else: self.nout = 1 Modified: trunk/numpy/lib/tests/test_function_base.py =================================================================== --- trunk/numpy/lib/tests/test_function_base.py 2008-07-08 07:49:25 UTC (rev 5359) +++ trunk/numpy/lib/tests/test_function_base.py 2008-07-08 08:24:37 UTC (rev 5360) @@ -615,16 +615,54 @@ x = array([5+6j, 1+1j, 1+10j, 10, 5+6j]) assert(all(unique(x) == [1+1j, 1+10j, 5+6j, 10])) -def compare_results(res,desired): - for i in range(len(desired)): - assert_array_equal(res[i],desired[i]) -class TestPiecewise(TestCase): +class TestPiecewise(NumpyTestCase): + def check_simple(self): + # Condition is single bool list + x = piecewise([0, 0], [True, False], [1]) + assert_array_equal(x, [1, 0]) + + # List of conditions: single bool list + x = piecewise([0, 0], [[True, False]], [1]) + assert_array_equal(x, [1, 0]) + + # Conditions is single bool array + x = piecewise([0, 0], array([True, False]), [1]) + assert_array_equal(x, [1, 0]) + + # Condition is single int array + x = piecewise([0, 0], array([1, 0]), [1]) + assert_array_equal(x, [1, 0]) + + # List of conditions: int array + x = piecewise([0, 0], [array([1, 0])], [1]) + assert_array_equal(x, [1, 0]) + + + x = piecewise([0, 0], [[False, True]], [lambda x: -1]) + assert_array_equal(x, [0, -1]) + + x = piecewise([1, 2], [[True, False], [False, True]], [3, 4]) + assert_array_equal(x, [3, 4]) + + def check_default(self): + # No value specified for x[1], should be 0 + x = piecewise([1, 2], [True, False], [2]) + assert_array_equal(x, [2, 0]) + + # Should set x[1] to 3 + x = piecewise([1, 2], [True, False], [2, 3]) + assert_array_equal(x, [2, 3]) + def test_0d(self): x = array(3) y = piecewise(x, x>3, [4, 0]) assert y.ndim == 0 assert y == 0 +def compare_results(res,desired): + for i in range(len(desired)): + assert_array_equal(res[i],desired[i]) + if __name__ == "__main__": run_module_suite() From numpy-svn at scipy.org Tue Jul 8 13:02:20 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 8 Jul 2008 12:02:20 -0500 (CDT) Subject: [Numpy-svn] r5361 - trunk/numpy/core/src Message-ID: <20080708170220.4FB1739C2B4@scipy.org> Author: oliphant Date: 2008-07-08 12:02:15 -0500 (Tue, 08 Jul 2008) New Revision: 5361 Modified: trunk/numpy/core/src/multiarraymodule.c Log: Fix ref-count leak in Ticket #843 Modified: trunk/numpy/core/src/multiarraymodule.c =================================================================== --- trunk/numpy/core/src/multiarraymodule.c 2008-07-08 08:24:37 UTC (rev 5360) +++ trunk/numpy/core/src/multiarraymodule.c 2008-07-08 17:02:15 UTC (rev 5361) @@ -2139,12 +2139,18 @@ if (scalar == PyArray_NOSCALAR) { return PyArray_CanCastSafely(thistype, neededtype); } + from = PyArray_DescrFromType(thistype); if (from->f->cancastscalarkindto && (castlist = from->f->cancastscalarkindto[scalar])) { while (*castlist != PyArray_NOTYPE) - if (*castlist++ == neededtype) return 1; + if (*castlist++ == neededtype) { + Py_DECREF(from); + return 1; + } } + Py_DECREF(from); + switch(scalar) { case PyArray_BOOL_SCALAR: case PyArray_OBJECT_SCALAR: From numpy-svn at scipy.org Tue Jul 8 13:13:58 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 8 Jul 2008 12:13:58 -0500 (CDT) Subject: [Numpy-svn] r5362 - trunk/numpy/core/src Message-ID: <20080708171358.744EE39C2B4@scipy.org> Author: oliphant Date: 2008-07-08 12:13:53 -0500 (Tue, 08 Jul 2008) New Revision: 5362 Modified: trunk/numpy/core/src/scalartypes.inc.src Log: Fix refleake discussed in #848. Only applied part of the patch. Modified: trunk/numpy/core/src/scalartypes.inc.src =================================================================== --- trunk/numpy/core/src/scalartypes.inc.src 2008-07-08 17:02:15 UTC (rev 5361) +++ trunk/numpy/core/src/scalartypes.inc.src 2008-07-08 17:13:53 UTC (rev 5362) @@ -1883,10 +1883,11 @@ _WORK at work@ - if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL; + if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL; typecode = PyArray_DescrFromType(PyArray_ at TYPE@); - Py_INCREF(typecode); + /* typecode is new reference and stolen by + PyArray_Scalar and others */ if (obj == NULL) { #if @default@ == 0 char *mem; From numpy-svn at scipy.org Tue Jul 8 21:55:35 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 8 Jul 2008 20:55:35 -0500 (CDT) Subject: [Numpy-svn] r5363 - trunk/numpy/random/mtrand Message-ID: <20080709015535.2463D39C10E@scipy.org> Author: rkern Date: 2008-07-08 20:55:33 -0500 (Tue, 08 Jul 2008) New Revision: 5363 Modified: trunk/numpy/random/mtrand/distributions.c Log: BUG: Make sure the Zipf results are within the allowable range. Modified: trunk/numpy/random/mtrand/distributions.c =================================================================== --- trunk/numpy/random/mtrand/distributions.c 2008-07-08 17:13:53 UTC (rev 5362) +++ trunk/numpy/random/mtrand/distributions.c 2008-07-09 01:55:33 UTC (rev 5363) @@ -676,16 +676,23 @@ { double T, U, V; long X; - double b; - - b = pow(2.0, a-1.0); + double am1, b; + + am1 = a - 1.0; + b = pow(2.0, am1); do { - U = rk_double(state); + U = 1.0-rk_double(state); V = rk_double(state); - X = (long)floor(pow(U, -1.0/(a-1.0))); - T = pow(1.0 + 1.0/X, a-1.0); - } while ((V *X*(T-1.0)/(b-1.0)) > (T/b)); + X = (long)floor(pow(U, -1.0/am1)); + /* The real result may be above what can be represented in a signed + * long. It will get casted to -sys.maxint-1. Since this is + * a straightforward rejection algorithm, we can just reject this value + * in the rejection condition below. This function then models a Zipf + * distribution truncated to sys.maxint. + */ + T = pow(1.0 + 1.0/X, am1); + } while (((V*X*(T-1.0)/(b-1.0)) > (T/b)) || X < 1); return X; } From numpy-svn at scipy.org Tue Jul 8 21:56:22 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 8 Jul 2008 20:56:22 -0500 (CDT) Subject: [Numpy-svn] r5364 - branches/1.1.x/numpy/random/mtrand Message-ID: <20080709015622.EF56739C10E@scipy.org> Author: rkern Date: 2008-07-08 20:56:22 -0500 (Tue, 08 Jul 2008) New Revision: 5364 Modified: branches/1.1.x/numpy/random/mtrand/distributions.c Log: BUG: Make sure the Zipf results are within the allowable range. Modified: branches/1.1.x/numpy/random/mtrand/distributions.c =================================================================== --- branches/1.1.x/numpy/random/mtrand/distributions.c 2008-07-09 01:55:33 UTC (rev 5363) +++ branches/1.1.x/numpy/random/mtrand/distributions.c 2008-07-09 01:56:22 UTC (rev 5364) @@ -676,16 +676,23 @@ { double T, U, V; long X; - double b; - - b = pow(2.0, a-1.0); + double am1, b; + + am1 = a - 1.0; + b = pow(2.0, am1); do { - U = rk_double(state); + U = 1.0-rk_double(state); V = rk_double(state); - X = (long)floor(pow(U, -1.0/(a-1.0))); - T = pow(1.0 + 1.0/X, a-1.0); - } while ((V *X*(T-1.0)/(b-1.0)) > (T/b)); + X = (long)floor(pow(U, -1.0/am1)); + /* The real result may be above what can be represented in a signed + * long. It will get casted to -sys.maxint-1. Since this is + * a straightforward rejection algorithm, we can just reject this value + * in the rejection condition below. This function then models a Zipf + * distribution truncated to sys.maxint. + */ + T = pow(1.0 + 1.0/X, am1); + } while (((V*X*(T-1.0)/(b-1.0)) > (T/b)) || X < 1); return X; } From numpy-svn at scipy.org Wed Jul 9 02:02:00 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 01:02:00 -0500 (CDT) Subject: [Numpy-svn] r5365 - in trunk/numpy: fft lib linalg numarray random Message-ID: <20080709060200.F39CD39C74F@scipy.org> Author: cdavid Date: 2008-07-09 01:01:49 -0500 (Wed, 09 Jul 2008) New Revision: 5365 Modified: trunk/numpy/fft/SConscript trunk/numpy/lib/SConscript trunk/numpy/linalg/SConscript trunk/numpy/numarray/SConscript trunk/numpy/random/SConscript Log: Use NumpyPythonExtension instead of DistutilsPythonExtension where possible. Modified: trunk/numpy/fft/SConscript =================================================================== --- trunk/numpy/fft/SConscript 2008-07-09 01:56:22 UTC (rev 5364) +++ trunk/numpy/fft/SConscript 2008-07-09 06:01:49 UTC (rev 5365) @@ -1,10 +1,9 @@ # Last Change: Thu Jun 12 06:00 PM 2008 J # vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths +from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) -fftpack_lite = env.DistutilsPythonExtension('fftpack_lite', +fftpack_lite = env.NumpyPythonExtension('fftpack_lite', source = ['fftpack_litemodule.c', 'fftpack.c']) Modified: trunk/numpy/lib/SConscript =================================================================== --- trunk/numpy/lib/SConscript 2008-07-09 01:56:22 UTC (rev 5364) +++ trunk/numpy/lib/SConscript 2008-07-09 06:01:49 UTC (rev 5365) @@ -1,9 +1,7 @@ # Last Change: Thu Jun 12 06:00 PM 2008 J # vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths +from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) - -_compiled_base = env.DistutilsPythonExtension('_compiled_base', +_compiled_base = env.NumpyPythonExtension('_compiled_base', source = ['src/_compiled_base.c']) Modified: trunk/numpy/linalg/SConscript =================================================================== --- trunk/numpy/linalg/SConscript 2008-07-09 01:56:22 UTC (rev 5364) +++ trunk/numpy/linalg/SConscript 2008-07-09 06:01:49 UTC (rev 5365) @@ -2,13 +2,12 @@ # vim:syntax=python import os.path -from numscons import GetNumpyEnvironment, scons_get_paths, \ +from numscons import GetNumpyEnvironment, \ scons_get_mathlib from numscons import CheckF77LAPACK from numscons import write_info env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK}) @@ -25,5 +24,5 @@ if not use_lapack: sources.extend(['python_xerbla.c', 'zlapack_lite.c', 'dlapack_lite.c', 'blas_lite.c', 'dlamch.c', 'f2c_lite.c']) -lapack_lite = env.DistutilsPythonExtension('lapack_lite', source = sources) +lapack_lite = env.NumpyPythonExtension('lapack_lite', source = sources) Modified: trunk/numpy/numarray/SConscript =================================================================== --- trunk/numpy/numarray/SConscript 2008-07-09 01:56:22 UTC (rev 5364) +++ trunk/numpy/numarray/SConscript 2008-07-09 06:01:49 UTC (rev 5365) @@ -1,9 +1,8 @@ # Last Change: Thu Jun 12 06:00 PM 2008 J # vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths +from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) env.Append(CPPPATH = ['numpy']) -_capi = env.DistutilsPythonExtension('_capi', source = ['_capi.c']) +_capi = env.NumpyPythonExtension('_capi', source = ['_capi.c']) Modified: trunk/numpy/random/SConscript =================================================================== --- trunk/numpy/random/SConscript 2008-07-09 01:56:22 UTC (rev 5364) +++ trunk/numpy/random/SConscript 2008-07-09 06:01:49 UTC (rev 5365) @@ -2,8 +2,7 @@ # vim:syntax=python import os -from numscons import GetNumpyEnvironment, scons_get_paths, \ - scons_get_mathlib +from numscons import GetNumpyEnvironment, scons_get_mathlib def CheckWincrypt(context): from copy import deepcopy @@ -28,7 +27,6 @@ return st[0] env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) mlib = scons_get_mathlib(env) env.AppendUnique(LIBS = mlib) @@ -43,4 +41,4 @@ ['mtrand.c', 'randomkit.c', 'initarray.c', 'distributions.c']] # XXX: Pyrex dependency -mtrand = env.DistutilsPythonExtension('mtrand', source = sources) +mtrand = env.NumpyPythonExtension('mtrand', source = sources) From numpy-svn at scipy.org Wed Jul 9 02:02:41 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 01:02:41 -0500 (CDT) Subject: [Numpy-svn] r5366 - trunk/numpy/distutils/command Message-ID: <20080709060241.4666039C756@scipy.org> Author: cdavid Date: 2008-07-09 01:02:36 -0500 (Wed, 09 Jul 2008) New Revision: 5366 Modified: trunk/numpy/distutils/command/scons.py Log: Bump min version for numscons to 0.8.2. Modified: trunk/numpy/distutils/command/scons.py =================================================================== --- trunk/numpy/distutils/command/scons.py 2008-07-09 06:01:49 UTC (rev 5365) +++ trunk/numpy/distutils/command/scons.py 2008-07-09 06:02:36 UTC (rev 5366) @@ -341,13 +341,18 @@ "this package " % str(e)) try: + minver = "0.8.2" from numscons import get_version - if get_version() < '0.8.0': + if get_version() < minver: raise ValueError() - except ImportError, ValueError: - raise RuntimeError("You need numscons >= 0.8.0 to build numpy "\ + except ImportError: + raise RuntimeError("You need numscons >= %s to build numpy "\ "with numscons (imported numscons path " \ - "is %s)." % numscons.__file__) + "is %s)." % (minver, numscons.__file__)) + except ValueError: + raise RuntimeError("You need numscons >= %s to build numpy "\ + "with numscons (detected %s )" \ + % (minver, get_version())) else: # nothing to do, just leave it here. From numpy-svn at scipy.org Wed Jul 9 02:03:47 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 01:03:47 -0500 (CDT) Subject: [Numpy-svn] r5367 - in trunk/numpy: fft lib linalg numarray random Message-ID: <20080709060347.91A6839C74F@scipy.org> Author: cdavid Date: 2008-07-09 01:03:35 -0500 (Wed, 09 Jul 2008) New Revision: 5367 Modified: trunk/numpy/fft/SConscript trunk/numpy/lib/SConscript trunk/numpy/linalg/SConscript trunk/numpy/numarray/SConscript trunk/numpy/random/SConscript Log: Simplify a bit more scons scripts. Modified: trunk/numpy/fft/SConscript =================================================================== --- trunk/numpy/fft/SConscript 2008-07-09 06:02:36 UTC (rev 5366) +++ trunk/numpy/fft/SConscript 2008-07-09 06:03:35 UTC (rev 5367) @@ -4,6 +4,5 @@ env = GetNumpyEnvironment(ARGUMENTS) -fftpack_lite = env.NumpyPythonExtension('fftpack_lite', - source = ['fftpack_litemodule.c', - 'fftpack.c']) +env.NumpyPythonExtension('fftpack_lite', + source = ['fftpack_litemodule.c', 'fftpack.c']) Modified: trunk/numpy/lib/SConscript =================================================================== --- trunk/numpy/lib/SConscript 2008-07-09 06:02:36 UTC (rev 5366) +++ trunk/numpy/lib/SConscript 2008-07-09 06:03:35 UTC (rev 5367) @@ -3,5 +3,4 @@ from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -_compiled_base = env.NumpyPythonExtension('_compiled_base', - source = ['src/_compiled_base.c']) +env.NumpyPythonExtension('_compiled_base', source = ['src/_compiled_base.c']) Modified: trunk/numpy/linalg/SConscript =================================================================== --- trunk/numpy/linalg/SConscript 2008-07-09 06:02:36 UTC (rev 5366) +++ trunk/numpy/linalg/SConscript 2008-07-09 06:03:35 UTC (rev 5367) @@ -1,16 +1,12 @@ # Last Change: Thu Jun 12 06:00 PM 2008 J # vim:syntax=python -import os.path - -from numscons import GetNumpyEnvironment, \ - scons_get_mathlib +from numscons import GetNumpyEnvironment, scons_get_mathlib from numscons import CheckF77LAPACK from numscons import write_info env = GetNumpyEnvironment(ARGUMENTS) -config = env.NumpyConfigure(custom_tests = - {'CheckLAPACK' : CheckF77LAPACK}) +config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK}) use_lapack = config.CheckLAPACK() @@ -24,5 +20,4 @@ if not use_lapack: sources.extend(['python_xerbla.c', 'zlapack_lite.c', 'dlapack_lite.c', 'blas_lite.c', 'dlamch.c', 'f2c_lite.c']) -lapack_lite = env.NumpyPythonExtension('lapack_lite', source = sources) - +env.NumpyPythonExtension('lapack_lite', source = sources) Modified: trunk/numpy/numarray/SConscript =================================================================== --- trunk/numpy/numarray/SConscript 2008-07-09 06:02:36 UTC (rev 5366) +++ trunk/numpy/numarray/SConscript 2008-07-09 06:03:35 UTC (rev 5367) @@ -5,4 +5,4 @@ env = GetNumpyEnvironment(ARGUMENTS) env.Append(CPPPATH = ['numpy']) -_capi = env.NumpyPythonExtension('_capi', source = ['_capi.c']) +env.NumpyPythonExtension('_capi', source = ['_capi.c']) Modified: trunk/numpy/random/SConscript =================================================================== --- trunk/numpy/random/SConscript 2008-07-09 06:02:36 UTC (rev 5366) +++ trunk/numpy/random/SConscript 2008-07-09 06:03:35 UTC (rev 5367) @@ -41,4 +41,4 @@ ['mtrand.c', 'randomkit.c', 'initarray.c', 'distributions.c']] # XXX: Pyrex dependency -mtrand = env.NumpyPythonExtension('mtrand', source = sources) +env.NumpyPythonExtension('mtrand', source = sources) From numpy-svn at scipy.org Wed Jul 9 02:05:23 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 01:05:23 -0500 (CDT) Subject: [Numpy-svn] r5368 - trunk/numpy/distutils Message-ID: <20080709060523.A818439C2F8@scipy.org> Author: cdavid Date: 2008-07-09 01:05:18 -0500 (Wed, 09 Jul 2008) New Revision: 5368 Modified: trunk/numpy/distutils/ccompiler.py Log: Fix distutils issue on AIX with aix compilers. Modified: trunk/numpy/distutils/ccompiler.py =================================================================== --- trunk/numpy/distutils/ccompiler.py 2008-07-09 06:03:35 UTC (rev 5367) +++ trunk/numpy/distutils/ccompiler.py 2008-07-09 06:05:18 UTC (rev 5368) @@ -299,7 +299,7 @@ cxx.compiler_so = [cxx.compiler_cxx[0]] + cxx.compiler_so[1:] if sys.platform.startswith('aix') and 'ld_so_aix' in cxx.linker_so[0]: # AIX needs the ld_so_aix script included with Python - cxx.linker_so = [cxx.linker_so[0]] + cxx.compiler_cxx[0] \ + cxx.linker_so = [cxx.linker_so[0], cxx.compiler_cxx[0]] \ + cxx.linker_so[2:] else: cxx.linker_so = [cxx.compiler_cxx[0]] + cxx.linker_so[1:] From numpy-svn at scipy.org Wed Jul 9 02:25:50 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 01:25:50 -0500 (CDT) Subject: [Numpy-svn] r5369 - in branches/1.1.x/numpy: . tests Message-ID: <20080709062550.2116239C57A@scipy.org> Author: cdavid Date: 2008-07-09 01:25:42 -0500 (Wed, 09 Jul 2008) New Revision: 5369 Modified: branches/1.1.x/numpy/ctypeslib.py branches/1.1.x/numpy/tests/test_ctypeslib.py Log: Merge revision 5236 to fix ctypes load_library. Modified: branches/1.1.x/numpy/ctypeslib.py =================================================================== --- branches/1.1.x/numpy/ctypeslib.py 2008-07-09 06:05:18 UTC (rev 5368) +++ branches/1.1.x/numpy/ctypeslib.py 2008-07-09 06:25:42 UTC (rev 5369) @@ -29,7 +29,10 @@ import warnings warnings.warn("All features of ctypes interface may not work " \ "with ctypes < 1.0.1") - if '.' not in libname: + + ext = os.path.splitext(libname)[1] + + if not ext: # Try to load library with platform-specific name, otherwise # default to libname.[so|pyd]. Sometimes, these files are built # erroneously on non-linux platforms. @@ -38,6 +41,8 @@ libname_ext.insert(0, '%s.dll' % libname) elif sys.platform == 'darwin': libname_ext.insert(0, '%s.dylib' % libname) + else: + libname_ext = [libname] loader_path = os.path.abspath(loader_path) if not os.path.isdir(loader_path): Modified: branches/1.1.x/numpy/tests/test_ctypeslib.py =================================================================== --- branches/1.1.x/numpy/tests/test_ctypeslib.py 2008-07-09 06:05:18 UTC (rev 5368) +++ branches/1.1.x/numpy/tests/test_ctypeslib.py 2008-07-09 06:25:42 UTC (rev 5369) @@ -12,6 +12,22 @@ " (import error was: %s)" % str(e) print msg + def check_basic2(self): + """Regression for #801: load_library with a full library name + (including extension) does not work.""" + try: + try: + from distutils import sysconfig + so = sysconfig.get_config_var('SO') + cdll = load_library('multiarray%s' % so, + np.core.multiarray.__file__) + except ImportError: + print "No distutils available, skipping test." + except ImportError, e: + msg = "ctypes is not available on this python: skipping the test" \ + " (import error was: %s)" % str(e) + print msg + class TestNdpointer(NumpyTestCase): def check_dtype(self): dt = np.intc From numpy-svn at scipy.org Wed Jul 9 02:30:40 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 01:30:40 -0500 (CDT) Subject: [Numpy-svn] r5370 - in branches/1.1.x: . numpy/distutils/command numpy/fft numpy/lib numpy/linalg numpy/numarray numpy/random Message-ID: <20080709063040.187E639C57A@scipy.org> Author: cdavid Date: 2008-07-09 01:30:24 -0500 (Wed, 09 Jul 2008) New Revision: 5370 Modified: branches/1.1.x/ branches/1.1.x/numpy/distutils/command/scons.py branches/1.1.x/numpy/fft/SConstruct branches/1.1.x/numpy/lib/SConstruct branches/1.1.x/numpy/linalg/SConstruct branches/1.1.x/numpy/numarray/SConstruct branches/1.1.x/numpy/random/SConstruct Log: Merge revision 5258 from trunk: some updates to scons scripts. Property changes on: branches/1.1.x ___________________________________________________________________ Name: svnmerge-integrated - /branches/aligned_alloca:1-5127 /branches/build_with_scons:1-4676 /branches/cdavid:1-5203 /branches/cleanconfig_rtm:1-4677 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /trunk:1-2871 + /branches/aligned_alloca:1-5127 /branches/build_with_scons:1-4676 /branches/cdavid:1-5257 /branches/cleanconfig_rtm:1-4677 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /trunk:1-2871 Modified: branches/1.1.x/numpy/distutils/command/scons.py =================================================================== --- branches/1.1.x/numpy/distutils/command/scons.py 2008-07-09 06:25:42 UTC (rev 5369) +++ branches/1.1.x/numpy/distutils/command/scons.py 2008-07-09 06:30:24 UTC (rev 5370) @@ -85,6 +85,8 @@ return 'g77' elif compiler.compiler_type == 'gnu95': return 'gfortran' + elif compiler.compiler_type == 'sun': + return 'sunf77' else: # XXX: Just give up for now, and use generic fortran compiler return 'fortran' @@ -196,6 +198,15 @@ raise ValueError(msg) return common +def is_bootstrapping(): + import __builtin__ + try: + __builtin__.__NUMPY_SETUP__ + return True + except AttributeError: + return False + __NUMPY_SETUP__ = False + class scons(old_build_ext): # XXX: add an option to the scons command for configuration (auto/force/cache). description = "Scons builder" @@ -303,6 +314,8 @@ else: # nothing to do, just leave it here. return + + print "is bootstrapping ? %s" % is_bootstrapping() # XXX: when a scons script is missing, scons only prints warnings, and # does not return a failure (status is 0). We have to detect this from # distutils (this cannot work for recursive scons builds...) @@ -326,6 +339,11 @@ post_hooks = self.post_hooks pkg_names = self.pkg_names + if is_bootstrapping(): + bootstrap = 1 + else: + bootstrap = 0 + for sconscript, pre_hook, post_hook, pkg_name in zip(sconscripts, pre_hooks, post_hooks, pkg_names): @@ -364,6 +382,7 @@ elif int(self.silent) == 3: cmd.append('-s') cmd.append('silent=%d' % int(self.silent)) + cmd.append('bootstrapping=%d' % bootstrap) cmdstr = ' '.join(cmd) if int(self.silent) < 1: log.info("Executing scons command (pkg is %s): %s ", pkg_name, cmdstr) Modified: branches/1.1.x/numpy/fft/SConstruct =================================================================== --- branches/1.1.x/numpy/fft/SConstruct 2008-07-09 06:25:42 UTC (rev 5369) +++ branches/1.1.x/numpy/fft/SConstruct 2008-07-09 06:30:24 UTC (rev 5370) @@ -1,8 +1,5 @@ -# Last Change: Thu Oct 18 09:00 PM 2007 J +# Last Change: Tue May 20 05:00 PM 2008 J # vim:syntax=python -import __builtin__ -__builtin__.__NUMPY_SETUP__ = True -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment, scons_get_paths env = GetNumpyEnvironment(ARGUMENTS) Modified: branches/1.1.x/numpy/lib/SConstruct =================================================================== --- branches/1.1.x/numpy/lib/SConstruct 2008-07-09 06:25:42 UTC (rev 5369) +++ branches/1.1.x/numpy/lib/SConstruct 2008-07-09 06:30:24 UTC (rev 5370) @@ -1,8 +1,5 @@ -# Last Change: Thu Oct 18 09:00 PM 2007 J +# Last Change: Tue May 20 05:00 PM 2008 J # vim:syntax=python -import __builtin__ -__builtin__.__NUMPY_SETUP__ = True -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment, scons_get_paths env = GetNumpyEnvironment(ARGUMENTS) Modified: branches/1.1.x/numpy/linalg/SConstruct =================================================================== --- branches/1.1.x/numpy/linalg/SConstruct 2008-07-09 06:25:42 UTC (rev 5369) +++ branches/1.1.x/numpy/linalg/SConstruct 2008-07-09 06:30:24 UTC (rev 5370) @@ -1,11 +1,7 @@ -# Last Change: Fri Nov 16 05:00 PM 2007 J +# Last Change: Tue May 20 05:00 PM 2008 J # vim:syntax=python import os.path -import __builtin__ -__builtin__.__NUMPY_SETUP__ = True - -from numpy.distutils.misc_util import get_numpy_include_dirs, get_mathlibs from numscons import GetNumpyEnvironment, scons_get_paths, \ scons_get_mathlib from numscons import CheckF77LAPACK @@ -27,7 +23,7 @@ sources = ['lapack_litemodule.c'] if not use_lapack: - sources.extend(['zlapack_lite.c', 'dlapack_lite.c', 'blas_lite.c', - 'dlamch.c', 'f2c_lite.c']) + sources.extend(['python_xerbla.c', 'zlapack_lite.c', 'dlapack_lite.c', + 'blas_lite.c', 'dlamch.c', 'f2c_lite.c']) lapack_lite = env.NumpyPythonExtension('lapack_lite', source = sources) Modified: branches/1.1.x/numpy/numarray/SConstruct =================================================================== --- branches/1.1.x/numpy/numarray/SConstruct 2008-07-09 06:25:42 UTC (rev 5369) +++ branches/1.1.x/numpy/numarray/SConstruct 2008-07-09 06:30:24 UTC (rev 5370) @@ -1,8 +1,5 @@ -# Last Change: Fri Oct 19 09:00 AM 2007 J +# Last Change: Tue May 20 05:00 PM 2008 J # vim:syntax=python -import __builtin__ -__builtin__.__NUMPY_SETUP__ = True -from numpy.distutils.misc_util import get_numpy_include_dirs from numscons import GetNumpyEnvironment, scons_get_paths env = GetNumpyEnvironment(ARGUMENTS) Modified: branches/1.1.x/numpy/random/SConstruct =================================================================== --- branches/1.1.x/numpy/random/SConstruct 2008-07-09 06:25:42 UTC (rev 5369) +++ branches/1.1.x/numpy/random/SConstruct 2008-07-09 06:30:24 UTC (rev 5370) @@ -1,11 +1,7 @@ -# Last Change: Tue Nov 13 11:00 PM 2007 J +# Last Change: Tue May 20 05:00 PM 2008 J # vim:syntax=python import os -import __builtin__ -__builtin__.__NUMPY_SETUP__ = True - -from numpy.distutils.misc_util import get_numpy_include_dirs, get_mathlibs from numscons import GetNumpyEnvironment, scons_get_paths, \ scons_get_mathlib From numpy-svn at scipy.org Wed Jul 9 04:13:59 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 03:13:59 -0500 (CDT) Subject: [Numpy-svn] r5371 - in trunk/numpy: . doc doc/reference Message-ID: <20080709081359.A0C7A39C663@scipy.org> Author: stefan Date: 2008-07-09 03:13:18 -0500 (Wed, 09 Jul 2008) New Revision: 5371 Added: trunk/numpy/doc/__init__.py trunk/numpy/doc/reference/ trunk/numpy/doc/reference/__init__.py trunk/numpy/doc/reference/broadcasting.py trunk/numpy/doc/reference/indexing.py Modified: trunk/numpy/__init__.py trunk/numpy/setup.py Log: Add numpy.doc topical documentation framework. Modified: trunk/numpy/__init__.py =================================================================== --- trunk/numpy/__init__.py 2008-07-09 06:30:24 UTC (rev 5370) +++ trunk/numpy/__init__.py 2008-07-09 08:13:18 UTC (rev 5371) @@ -108,6 +108,7 @@ import random import ctypeslib import ma + import doc # Make these accessible from numpy name-space # but not imported in from numpy import * @@ -119,5 +120,5 @@ 'show_config']) __all__.extend(core.__all__) __all__.extend(lib.__all__) - __all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma']) + __all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma', 'doc']) Added: trunk/numpy/doc/__init__.py =================================================================== --- trunk/numpy/doc/__init__.py 2008-07-09 06:30:24 UTC (rev 5370) +++ trunk/numpy/doc/__init__.py 2008-07-09 08:13:18 UTC (rev 5371) @@ -0,0 +1,2 @@ +from numpy.doc.reference import * +del reference Added: trunk/numpy/doc/reference/__init__.py =================================================================== --- trunk/numpy/doc/reference/__init__.py 2008-07-09 06:30:24 UTC (rev 5370) +++ trunk/numpy/doc/reference/__init__.py 2008-07-09 08:13:18 UTC (rev 5371) @@ -0,0 +1,11 @@ +import os + +ref_dir = os.path.join(os.path.dirname(__file__)) + +__all__ = [f[:-3] for f in os.listdir(ref_dir) if f.endswith('.py') and + not f.startswith('__')] + +__doc__ = 'The following topics are available:\n' + \ + '\n - '.join([''] + __all__) + +__all__.extend(['__doc__']) Added: trunk/numpy/doc/reference/broadcasting.py =================================================================== --- trunk/numpy/doc/reference/broadcasting.py 2008-07-09 06:30:24 UTC (rev 5370) +++ trunk/numpy/doc/reference/broadcasting.py 2008-07-09 08:13:18 UTC (rev 5371) @@ -0,0 +1,9 @@ +""" + +======================== +Broadcasting over arrays +======================== + +Placeholder for broadcasting documentation. + +""" Added: trunk/numpy/doc/reference/indexing.py =================================================================== --- trunk/numpy/doc/reference/indexing.py 2008-07-09 06:30:24 UTC (rev 5370) +++ trunk/numpy/doc/reference/indexing.py 2008-07-09 08:13:18 UTC (rev 5371) @@ -0,0 +1,9 @@ +""" + +============== +Array indexing +============== + +Placeholder for array indexing documentation. + +""" Modified: trunk/numpy/setup.py =================================================================== --- trunk/numpy/setup.py 2008-07-09 06:30:24 UTC (rev 5370) +++ trunk/numpy/setup.py 2008-07-09 08:13:18 UTC (rev 5371) @@ -14,6 +14,8 @@ config.add_subpackage('linalg') config.add_subpackage('random') config.add_subpackage('ma') + config.add_subpackage('doc') + config.add_subpackage('doc/reference') config.add_data_dir('doc') config.add_data_dir('tests') config.make_config_py() # installs __config__.py From numpy-svn at scipy.org Wed Jul 9 04:50:00 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 03:50:00 -0500 (CDT) Subject: [Numpy-svn] r5372 - trunk/numpy/doc Message-ID: <20080709085000.CC6EE39C07A@scipy.org> Author: stefan Date: 2008-07-09 03:49:28 -0500 (Wed, 09 Jul 2008) New Revision: 5372 Modified: trunk/numpy/doc/EXAMPLE_DOCSTRING.txt Log: Fix example docstring. Modified: trunk/numpy/doc/EXAMPLE_DOCSTRING.txt =================================================================== --- trunk/numpy/doc/EXAMPLE_DOCSTRING.txt 2008-07-09 08:13:18 UTC (rev 5371) +++ trunk/numpy/doc/EXAMPLE_DOCSTRING.txt 2008-07-09 08:49:28 UTC (rev 5372) @@ -72,9 +72,10 @@ >>> mean = [0,0] >>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis +>>> x,y = np.random.multivariate_normal(mean,cov,5000).T ->>> x,y = numpy.multivariate_normal(mean,cov,5000).T ->>> pyplot.plot(x,y,'x'); pyplot.axis('equal'); pyplot.show() +>>> import matplotlib.pyplot as plt +>>> plt.plot(x,y,'x'); plt.axis('equal'); pyplot.show() Note that the covariance matrix must be non-negative definite. @@ -89,7 +90,7 @@ -------- >>> mean = (1,2) >>> cov = [[1,0],[1,0]] ->>> x = multivariate_normal(mean,cov,(3,3)) +>>> x = np.random.multivariate_normal(mean,cov,(3,3)) >>> x.shape (3, 3, 2) From numpy-svn at scipy.org Wed Jul 9 06:18:01 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 05:18:01 -0500 (CDT) Subject: [Numpy-svn] r5373 - in branches/1.1.x/numpy: core distutils/command fft lib linalg numarray random Message-ID: <20080709101801.36AB439C15C@scipy.org> Author: cdavid Date: 2008-07-09 05:17:18 -0500 (Wed, 09 Jul 2008) New Revision: 5373 Added: branches/1.1.x/numpy/core/SConscript branches/1.1.x/numpy/core/SConstruct branches/1.1.x/numpy/fft/SConscript branches/1.1.x/numpy/fft/SConstruct branches/1.1.x/numpy/lib/SConscript branches/1.1.x/numpy/lib/SConstruct branches/1.1.x/numpy/linalg/SConscript branches/1.1.x/numpy/linalg/SConstruct branches/1.1.x/numpy/numarray/SConscript branches/1.1.x/numpy/numarray/SConstruct branches/1.1.x/numpy/random/SConscript branches/1.1.x/numpy/random/SConstruct Removed: branches/1.1.x/numpy/core/SConstruct branches/1.1.x/numpy/fft/SConstruct branches/1.1.x/numpy/lib/SConstruct branches/1.1.x/numpy/linalg/SConstruct branches/1.1.x/numpy/numarray/SConstruct branches/1.1.x/numpy/random/SConstruct Modified: branches/1.1.x/numpy/core/scons_support.py branches/1.1.x/numpy/core/setupscons.py branches/1.1.x/numpy/distutils/command/scons.py Log: Merge revisions 5266:5288: update scons scripts to new variant_dir conventions in numscons 0.8 ------------------------------------------------------------------------ r5267 | cdavid | 2008-06-12 08:35:22 +0200 (Thu, 12 Jun 2008) | 1 line scons command: set distutils libdir relatively to build directory. ------------------------------------------------------------------------ r5268 | cdavid | 2008-06-12 09:20:28 +0200 (Thu, 12 Jun 2008) | 1 line Remove distutils_dirs_emitter hacks: no need anymore since we use variant_dir. ------------------------------------------------------------------------ r5269 | cdavid | 2008-06-12 09:23:31 +0200 (Thu, 12 Jun 2008) | 1 line variant_dir: Rename SConscript for numpy.core. ------------------------------------------------------------------------ r5270 | cdavid | 2008-06-12 09:24:09 +0200 (Thu, 12 Jun 2008) | 1 line Add boilerplate SConstruct to set variant dir transparantly. ------------------------------------------------------------------------ r5271 | cdavid | 2008-06-12 09:28:27 +0200 (Thu, 12 Jun 2008) | 1 line Adapt SConscript to new architecture for build dir. ------------------------------------------------------------------------ r5272 | cdavid | 2008-06-12 09:43:27 +0200 (Thu, 12 Jun 2008) | 1 line Adapt numpyconfig.h location in setup.py file. ------------------------------------------------------------------------ r5273 | cdavid | 2008-06-12 10:59:20 +0200 (Thu, 12 Jun 2008) | 1 line When src_dir is not null, takes it into account to retrieve distutils libdir. ------------------------------------------------------------------------ r5274 | cdavid | 2008-06-12 11:01:13 +0200 (Thu, 12 Jun 2008) | 1 line Adapt numpy.lib to new scons build_dir behavior. ------------------------------------------------------------------------ r5275 | cdavid | 2008-06-12 11:48:42 +0200 (Thu, 12 Jun 2008) | 1 line Set numpy include path relatively to top setup callee when bootstrapping. ------------------------------------------------------------------------ r5276 | cdavid | 2008-06-12 11:49:16 +0200 (Thu, 12 Jun 2008) | 1 line Adapat numpy.lib scons build to new build_dir conventions. ------------------------------------------------------------------------ r5277 | cdavid | 2008-06-12 11:55:30 +0200 (Thu, 12 Jun 2008) | 1 line Adapt numpy.numarray to new build dir convention. ------------------------------------------------------------------------ r5278 | cdavid | 2008-06-12 11:56:55 +0200 (Thu, 12 Jun 2008) | 1 line Adapt numpy.fft to new build dir conventions. ------------------------------------------------------------------------ r5279 | cdavid | 2008-06-12 12:00:37 +0200 (Thu, 12 Jun 2008) | 1 line adapt numpy.linalg to new scons build_dir architecture. ------------------------------------------------------------------------ r5280 | cdavid | 2008-06-12 12:05:12 +0200 (Thu, 12 Jun 2008) | 1 line adapt numpy.random to new scons build_dir architecture. ------------------------------------------------------------------------ r5281 | cdavid | 2008-06-12 12:56:20 +0200 (Thu, 12 Jun 2008) | 1 line Make sure we are using numscons 0.8.0 or above. ------------------------------------------------------------------------ r5282 | cdavid | 2008-06-12 17:16:07 +0200 (Thu, 12 Jun 2008) | 1 line Do not fail scons command when cxx compiler is not available. ------------------------------------------------------------------------ r5283 | cdavid | 2008-06-14 08:06:13 +0200 (Sat, 14 Jun 2008) | 1 line Fix dotblas compilation on mac os X: scons scanner is not smart enough to interpret #include CPP_MACRO. Copied: branches/1.1.x/numpy/core/SConscript (from rev 5283, trunk/numpy/core/SConscript) Deleted: branches/1.1.x/numpy/core/SConstruct =================================================================== --- branches/1.1.x/numpy/core/SConstruct 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/core/SConstruct 2008-07-09 10:17:18 UTC (rev 5373) @@ -1,270 +0,0 @@ -# Last Change: Mon Apr 21 07:00 PM 2008 J -# vim:syntax=python -import os -import sys -from os.path import join as pjoin, basename as pbasename, dirname as pdirname -from copy import deepcopy - -from numscons import get_python_inc, get_pythonlib_dir -from numscons import GetNumpyEnvironment -from numscons import CheckCBLAS -from numscons import write_info - -from scons_support import CheckBrokenMathlib, define_no_smp, \ - check_mlib, check_mlibs, is_npy_no_signal -from scons_support import array_api_gen_bld, ufunc_api_gen_bld, template_bld, \ - umath_bld - - -env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = [get_python_inc()]) -if os.name == 'nt': - # NT needs the pythonlib to run any code importing Python.h, including - # simple code using only typedef and so on, so we need it for configuration - # checks - env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) - -#======================= -# Starting Configuration -#======================= -config = env.NumpyConfigure(custom_tests = {'CheckBrokenMathlib' : CheckBrokenMathlib, - 'CheckCBLAS' : CheckCBLAS}, config_h = pjoin(env['build_dir'], 'config.h')) - -# numpyconfig_sym will keep the values of some configuration variables, the one -# needed for the public numpy API. - -# Convention: list of tuples (definition, value). value: -# - 0: #undef definition -# - 1: #define definition -# - string: #define definition value -numpyconfig_sym = [] - -#--------------- -# Checking Types -#--------------- -if not config.CheckHeader("Python.h"): - raise RuntimeError("Error: Python.h header is not found (or cannot be " -"compiled). On linux, check that you have python-dev/python-devel packages. On" -" windows, check \ that you have the platform SDK.") - -def check_type(type, include = None): - st = config.CheckTypeSize(type, includes = include) - type = type.replace(' ', '_') - if st: - numpyconfig_sym.append(('SIZEOF_%s' % type.upper(), '%d' % st)) - else: - numpyconfig_sym.append(('SIZEOF_%s' % type.upper(), 0)) - -for type in ('short', 'int', 'long', 'float', 'double', 'long double'): - check_type(type) - -for type in ('Py_intptr_t',): - check_type(type, include = "#include \n") - -# We check declaration AND type because that's how distutils does it. -if config.CheckDeclaration('PY_LONG_LONG', includes = '#include \n'): - st = config.CheckTypeSize('PY_LONG_LONG', - includes = '#include \n') - assert not st == 0 - numpyconfig_sym.append(('DEFINE_NPY_SIZEOF_LONGLONG', - '#define NPY_SIZEOF_LONGLONG %d' % st)) - numpyconfig_sym.append(('DEFINE_NPY_SIZEOF_PY_LONG_LONG', - '#define NPY_SIZEOF_PY_LONG_LONG %d' % st)) -else: - numpyconfig_sym.append(('DEFINE_NPY_SIZEOF_LONGLONG', '')) - numpyconfig_sym.append(('DEFINE_NPY_SIZEOF_PY_LONG_LONG', '')) - -if not config.CheckDeclaration('CHAR_BIT', includes= '#include \n'): - raise RuntimeError(\ -"""Config wo CHAR_BIT is not supported with scons: please contact the -maintainer (cdavid)""") - -#---------------------- -# Checking signal stuff -#---------------------- -if is_npy_no_signal(): - numpyconfig_sym.append(('DEFINE_NPY_NO_SIGNAL', '#define NPY_NO_SIGNAL\n')) - config.Define('__NPY_PRIVATE_NO_SIGNAL', - comment = "define to 1 to disable SMP support ") -else: - numpyconfig_sym.append(('DEFINE_NPY_NO_SIGNAL', '')) - -#--------------------- -# Checking SMP option -#--------------------- -if define_no_smp(): - nosmp = 1 -else: - nosmp = 0 -numpyconfig_sym.append(('NPY_NO_SMP', nosmp)) - -#---------------------- -# Checking the mathlib -#---------------------- -mlibs = [[], ['m'], ['cpml']] -mathlib = os.environ.get('MATHLIB') -if mathlib: - mlibs.insert(0, mathlib) - -mlib = check_mlibs(config, mlibs) - -# XXX: this is ugly: mathlib has nothing to do in a public header file -numpyconfig_sym.append(('MATHLIB', ','.join(mlib))) - -#---------------------------------- -# Checking the math funcs available -#---------------------------------- -# Function to check: -mfuncs = ('expl', 'expf', 'log1p', 'expm1', 'asinh', 'atanhf', 'atanhl', - 'isnan', 'isinf', 'rint') - -# Set value to 1 for each defined function (in math lib) -mfuncs_defined = dict([(f, 0) for f in mfuncs]) - -# TODO: checklib vs checkfunc ? -def check_func(f): - """Check that f is available in mlib, and add the symbol appropriately. """ - st = config.CheckDeclaration(f, language = 'C', includes = "#include ") - if st: - st = config.CheckFunc(f, language = 'C') - if st: - mfuncs_defined[f] = 1 - else: - mfuncs_defined[f] = 0 - -for f in mfuncs: - check_func(f) - -if mfuncs_defined['expl'] == 1: - config.Define('HAVE_LONGDOUBLE_FUNCS', - comment = 'Define to 1 if long double funcs are available') -if mfuncs_defined['expf'] == 1: - config.Define('HAVE_FLOAT_FUNCS', - comment = 'Define to 1 if long double funcs are available') -if mfuncs_defined['asinh'] == 1: - config.Define('HAVE_INVERSE_HYPERBOLIC', - comment = 'Define to 1 if inverse hyperbolic funcs are '\ - 'available') -if mfuncs_defined['atanhf'] == 1: - config.Define('HAVE_INVERSE_HYPERBOLIC_FLOAT', - comment = 'Define to 1 if inverse hyperbolic float funcs '\ - 'are available') -if mfuncs_defined['atanhl'] == 1: - config.Define('HAVE_INVERSE_HYPERBOLIC_LONGDOUBLE', - comment = 'Define to 1 if inverse hyperbolic long double '\ - 'funcs are available') - -#------------------------------------------------------- -# Define the function PyOS_ascii_strod if not available -#------------------------------------------------------- -if not config.CheckDeclaration('PyOS_ascii_strtod', - includes = "#include "): - if config.CheckFunc('strtod'): - config.Define('PyOS_ascii_strtod', 'strtod', - "Define to a function to use as a replacement for "\ - "PyOS_ascii_strtod if not available in python header") - -#------------------------------------ -# DISTUTILS Hack on AMD64 on windows -#------------------------------------ -# XXX: this is ugly -if sys.platform=='win32' or os.name=='nt': - from distutils.msvccompiler import get_build_architecture - a = get_build_architecture() - print 'BUILD_ARCHITECTURE: %r, os.name=%r, sys.platform=%r' % \ - (a, os.name, sys.platform) - if a == 'AMD64': - distutils_use_sdk = 1 - config.Define('DISTUTILS_USE_SDK', distutils_use_sdk, - "define to 1 to disable SMP support ") - -#-------------- -# Checking Blas -#-------------- -if config.CheckCBLAS(): - build_blasdot = 1 -else: - build_blasdot = 0 - -config.Finish() -write_info(env) - -#========== -# Build -#========== - -#--------------------------------------- -# Generate the public configuration file -#--------------------------------------- -config_dict = {} -# XXX: this is ugly, make the API for config.h and numpyconfig.h similar -for key, value in numpyconfig_sym: - config_dict['@%s@' % key] = str(value) -env['SUBST_DICT'] = config_dict - -include_dir = 'include/numpy' -env.SubstInFile(pjoin(env['build_dir'], 'numpyconfig.h'), - pjoin(env['src_dir'], include_dir, 'numpyconfig.h.in')) - -env['CONFIG_H_GEN'] = numpyconfig_sym - -#--------------------------- -# Builder for generated code -#--------------------------- -env.Append(BUILDERS = {'GenerateMultiarrayApi' : array_api_gen_bld, - 'GenerateUfuncApi' : ufunc_api_gen_bld, - 'GenerateFromTemplate' : template_bld, - 'GenerateUmath' : umath_bld}) - -#------------------------ -# Generate generated code -#------------------------ -scalartypes_src = env.GenerateFromTemplate(pjoin('src', 'scalartypes.inc.src')) -arraytypes_src = env.GenerateFromTemplate(pjoin('src', 'arraytypes.inc.src')) -sortmodule_src = env.GenerateFromTemplate(pjoin('src', '_sortmodule.c.src')) -umathmodule_src = env.GenerateFromTemplate(pjoin('src', 'umathmodule.c.src')) -scalarmathmodule_src = env.GenerateFromTemplate( - pjoin('src', 'scalarmathmodule.c.src')) - -umath = env.GenerateUmath('__umath_generated', - pjoin('code_generators', 'generate_umath.py')) - -multiarray_api = env.GenerateMultiarrayApi('multiarray_api', - [ pjoin('code_generators', 'array_api_order.txt'), - pjoin('code_generators', 'multiarray_api_order.txt')]) - -ufunc_api = env.GenerateUfuncApi('ufunc_api', - pjoin('code_generators', 'ufunc_api_order.txt')) - -env.Append(CPPPATH = [pjoin(env['src_dir'], 'include'), env['build_dir']]) - -#----------------- -# Build multiarray -#----------------- -multiarray_src = [pjoin('src', 'multiarraymodule.c')] -multiarray = env.NumpyPythonExtension('multiarray', source = multiarray_src) - -#------------------ -# Build sort module -#------------------ -sort = env.NumpyPythonExtension('_sort', source = sortmodule_src) - -#------------------- -# Build umath module -#------------------- -umathmodule = env.NumpyPythonExtension('umath', source = umathmodule_src) - -#------------------------ -# Build scalarmath module -#------------------------ -scalarmathmodule = env.NumpyPythonExtension('scalarmath', - source = scalarmathmodule_src) - -#---------------------- -# Build _dotblas module -#---------------------- -if build_blasdot: - dotblas_src = [pjoin('blasdot', i) for i in ['_dotblas.c']] - blasenv = env.Clone() - blasenv.Append(CPPPATH = pjoin(env['src_dir'], 'blasdot')) - dotblas = blasenv.NumpyPythonExtension('_dotblas', source = dotblas_src) Copied: branches/1.1.x/numpy/core/SConstruct (from rev 5283, trunk/numpy/core/SConstruct) Modified: branches/1.1.x/numpy/core/scons_support.py =================================================================== --- branches/1.1.x/numpy/core/scons_support.py 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/core/scons_support.py 2008-07-09 10:17:18 UTC (rev 5373) @@ -1,4 +1,4 @@ -#! Last Change: Mon Apr 21 07:00 PM 2008 J +#! Last Change: Thu Jun 12 02:00 PM 2008 J """Code to support special facilities to scons which are only useful for numpy.core, hence not put into numpy.distutils.scons""" @@ -16,10 +16,6 @@ from numscons.numdist import process_c_str as process_str from numscons.core.utils import rsplit, isstring -try: - from numscons import distutils_dirs_emitter -except ImportError: - raise ImportError("You need numscons >= 0.5.2") import SCons.Node import SCons @@ -189,16 +185,14 @@ return nosmp == 1 array_api_gen_bld = Builder(action = Action(do_generate_array_api, '$ARRAPIGENCOMSTR'), - emitter = [generate_api_emitter, - distutils_dirs_emitter]) + emitter = generate_api_emitter) + ufunc_api_gen_bld = Builder(action = Action(do_generate_ufunc_api, '$UFUNCAPIGENCOMSTR'), - emitter = [generate_api_emitter, - distutils_dirs_emitter]) + emitter = generate_api_emitter) template_bld = Builder(action = Action(generate_from_template, '$TEMPLATECOMSTR'), - emitter = [generate_from_template_emitter, - distutils_dirs_emitter]) + emitter = generate_from_template_emitter) umath_bld = Builder(action = Action(generate_umath, '$UMATHCOMSTR'), - emitter = [generate_umath_emitter, distutils_dirs_emitter]) + emitter = generate_umath_emitter) Modified: branches/1.1.x/numpy/core/setupscons.py =================================================================== --- branches/1.1.x/numpy/core/setupscons.py 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/core/setupscons.py 2008-07-09 10:17:18 UTC (rev 5373) @@ -50,7 +50,7 @@ # XXX: I really have to think about how to communicate path info # between scons and distutils, and set the options at one single # location. - target = join(scons_build_dir, local_dir, 'numpyconfig.h') + target = join(scons_build_dir, local_dir, 'include/numpy/numpyconfig.h') incl_dir = os.path.dirname(target) if incl_dir not in config.numpy_include_dirs: config.numpy_include_dirs.append(incl_dir) Modified: branches/1.1.x/numpy/distutils/command/scons.py =================================================================== --- branches/1.1.x/numpy/distutils/command/scons.py 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/distutils/command/scons.py 2008-07-09 10:17:18 UTC (rev 5373) @@ -10,7 +10,6 @@ from numpy.distutils.fcompiler import FCompiler from numpy.distutils.exec_command import find_executable from numpy.distutils import log -from numpy.distutils.misc_util import get_numpy_include_dirs def get_scons_build_dir(): """Return the top path where everything produced by scons will be put. @@ -38,6 +37,14 @@ from numscons import get_scons_path return get_scons_path() +def get_distutils_libdir(cmd, sconscript_path): + """Returns the path where distutils install libraries, relatively to the + scons build directory.""" + from numscons import get_scons_build_dir + scdir = pjoin(get_scons_build_dir(), pdirname(sconscript_path)) + n = scdir.count(os.sep) + return pjoin(os.sep.join([os.pardir for i in range(n+1)]), cmd.build_lib) + def get_python_exec_invoc(): """This returns the python executable from which this file is invocated.""" # Do we need to take into account the PYTHONPATH, in a cross platform way, @@ -49,6 +56,21 @@ import sys return sys.executable +def get_numpy_include_dirs(sconscript_path): + """Return include dirs for numpy. + + The paths are relatively to the setup.py script path.""" + from numpy.distutils.misc_util import get_numpy_include_dirs as _incdir + from numscons import get_scons_build_dir + scdir = pjoin(get_scons_build_dir(), pdirname(sconscript_path)) + n = scdir.count(os.sep) + + dirs = _incdir() + rdirs = [] + for d in dirs: + rdirs.append(pjoin(os.sep.join([os.pardir for i in range(n+1)]), d)) + return rdirs + def dirl_to_str(dirlist): """Given a list of directories, returns a string where the paths are concatenated by the path separator. @@ -298,7 +320,10 @@ cxxcompiler.customize(self.distribution, need_cxx = 1) cxxcompiler.customize_cmd(self) self.cxxcompiler = cxxcompiler.cxx_compiler() - #print self.cxxcompiler.compiler_cxx[0] + try: + get_cxx_tool_path(self.cxxcompiler) + except DistutilsSetupError: + self.cxxcompiler = None if self.package_list: self.package_list = parse_package_list(self.package_list) @@ -311,6 +336,16 @@ raise RuntimeError("importing numscons failed (error was %s), using " \ "scons within distutils is not possible without " "this package " % str(e)) + + try: + from numscons import get_version + if get_version() < '0.8.0': + raise ValueError() + except ImportError, ValueError: + raise RuntimeError("You need numscons >= 0.8.0 to build numpy "\ + "with numscons (imported numscons path " \ + "is %s)." % numscons.__file__) + else: # nothing to do, just leave it here. return @@ -358,7 +393,8 @@ cmd.append('pkg_name="%s"' % pkg_name) #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib, # pdirname(sconscript)))) - cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib))) + cmd.append('distutils_libdir=%s' % + protect_path(get_distutils_libdir(self, sconscript))) if not self._bypass_distutils_cc: cmd.append('cc_opt=%s' % self.scons_compiler) @@ -375,7 +411,7 @@ cmd.append('cxx_opt=%s' % dist2sconscxx(self.cxxcompiler)) cmd.append('cxx_opt_path=%s' % protect_path(get_cxx_tool_path(self.cxxcompiler))) - cmd.append('include_bootstrap=%s' % dirl_to_str(get_numpy_include_dirs())) + cmd.append('include_bootstrap=%s' % dirl_to_str(get_numpy_include_dirs(sconscript))) if self.silent: if int(self.silent) == 2: cmd.append('-Q') Copied: branches/1.1.x/numpy/fft/SConscript (from rev 5283, trunk/numpy/fft/SConscript) Deleted: branches/1.1.x/numpy/fft/SConstruct =================================================================== --- branches/1.1.x/numpy/fft/SConstruct 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/fft/SConstruct 2008-07-09 10:17:18 UTC (rev 5373) @@ -1,10 +0,0 @@ -# Last Change: Tue May 20 05:00 PM 2008 J -# vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths - -env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) - -fftpack_lite = env.NumpyPythonExtension('fftpack_lite', - source = ['fftpack_litemodule.c', - 'fftpack.c']) Copied: branches/1.1.x/numpy/fft/SConstruct (from rev 5283, trunk/numpy/fft/SConstruct) Copied: branches/1.1.x/numpy/lib/SConscript (from rev 5283, trunk/numpy/lib/SConscript) Deleted: branches/1.1.x/numpy/lib/SConstruct =================================================================== --- branches/1.1.x/numpy/lib/SConstruct 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/lib/SConstruct 2008-07-09 10:17:18 UTC (rev 5373) @@ -1,9 +0,0 @@ -# Last Change: Tue May 20 05:00 PM 2008 J -# vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths - -env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) - -_compiled_base = env.NumpyPythonExtension('_compiled_base', - source = ['src/_compiled_base.c']) Copied: branches/1.1.x/numpy/lib/SConstruct (from rev 5283, trunk/numpy/lib/SConstruct) Copied: branches/1.1.x/numpy/linalg/SConscript (from rev 5283, trunk/numpy/linalg/SConscript) Deleted: branches/1.1.x/numpy/linalg/SConstruct =================================================================== --- branches/1.1.x/numpy/linalg/SConstruct 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/linalg/SConstruct 2008-07-09 10:17:18 UTC (rev 5373) @@ -1,29 +0,0 @@ -# Last Change: Tue May 20 05:00 PM 2008 J -# vim:syntax=python -import os.path - -from numscons import GetNumpyEnvironment, scons_get_paths, \ - scons_get_mathlib -from numscons import CheckF77LAPACK -from numscons import write_info - -env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) - -config = env.NumpyConfigure(custom_tests = - {'CheckLAPACK' : CheckF77LAPACK}) - -use_lapack = config.CheckLAPACK() - -mlib = scons_get_mathlib(env) -env.AppendUnique(LIBS = mlib) - -config.Finish() -write_info(env) - -sources = ['lapack_litemodule.c'] -if not use_lapack: - sources.extend(['python_xerbla.c', 'zlapack_lite.c', 'dlapack_lite.c', - 'blas_lite.c', 'dlamch.c', 'f2c_lite.c']) -lapack_lite = env.NumpyPythonExtension('lapack_lite', source = sources) - Copied: branches/1.1.x/numpy/linalg/SConstruct (from rev 5283, trunk/numpy/linalg/SConstruct) Copied: branches/1.1.x/numpy/numarray/SConscript (from rev 5283, trunk/numpy/numarray/SConscript) Deleted: branches/1.1.x/numpy/numarray/SConstruct =================================================================== --- branches/1.1.x/numpy/numarray/SConstruct 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/numarray/SConstruct 2008-07-09 10:17:18 UTC (rev 5373) @@ -1,9 +0,0 @@ -# Last Change: Tue May 20 05:00 PM 2008 J -# vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths - -env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) -env.Append(CPPPATH = env['src_dir']) - -_capi = env.NumpyPythonExtension('_capi', source = ['_capi.c']) Copied: branches/1.1.x/numpy/numarray/SConstruct (from rev 5283, trunk/numpy/numarray/SConstruct) Copied: branches/1.1.x/numpy/random/SConscript (from rev 5283, trunk/numpy/random/SConscript) Deleted: branches/1.1.x/numpy/random/SConstruct =================================================================== --- branches/1.1.x/numpy/random/SConstruct 2008-07-09 08:49:28 UTC (rev 5372) +++ branches/1.1.x/numpy/random/SConstruct 2008-07-09 10:17:18 UTC (rev 5373) @@ -1,46 +0,0 @@ -# Last Change: Tue May 20 05:00 PM 2008 J -# vim:syntax=python -import os - -from numscons import GetNumpyEnvironment, scons_get_paths, \ - scons_get_mathlib - -def CheckWincrypt(context): - from copy import deepcopy - src = """\ -/* check to see if _WIN32 is defined */ -int main(int argc, char *argv[]) -{ -#ifdef _WIN32 - return 0; -#else - return 1; -#endif -} -""" - - context.Message("Checking if using wincrypt ... ") - st = context.env.TryRun(src, '.C') - if st[0] == 0: - context.Result('No') - else: - context.Result('Yes') - return st[0] - -env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) - -mlib = scons_get_mathlib(env) -env.AppendUnique(LIBS = mlib) - -# On windows, see if we should use Advapi32 -if os.name == 'nt': - config = env.NumpyConfigure(custom_tests = {'CheckWincrypt' : CheckWincrypt}) - if config.CheckWincrypt: - config.env.AppendUnique(LIBS = 'Advapi32') - -sources = [os.path.join('mtrand', x) for x in - ['mtrand.c', 'randomkit.c', 'initarray.c', 'distributions.c']] - -# XXX: Pyrex dependency -mtrand = env.NumpyPythonExtension('mtrand', source = sources) Copied: branches/1.1.x/numpy/random/SConstruct (from rev 5283, trunk/numpy/random/SConstruct) From numpy-svn at scipy.org Wed Jul 9 06:23:56 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 05:23:56 -0500 (CDT) Subject: [Numpy-svn] r5374 - branches/1.1.x/numpy/core Message-ID: <20080709102356.AA73939C15C@scipy.org> Author: cdavid Date: 2008-07-09 05:23:50 -0500 (Wed, 09 Jul 2008) New Revision: 5374 Modified: branches/1.1.x/numpy/core/SConscript Log: merge 5304: update dotblas build with numscons. Modified: branches/1.1.x/numpy/core/SConscript =================================================================== --- branches/1.1.x/numpy/core/SConscript 2008-07-09 10:17:18 UTC (rev 5373) +++ branches/1.1.x/numpy/core/SConscript 2008-07-09 10:23:50 UTC (rev 5374) @@ -263,5 +263,12 @@ #---------------------- if build_blasdot: dotblas_src = [pjoin('blasdot', i) for i in ['_dotblas.c']] - dotblas = env.DistutilsPythonExtension('_dotblas', source = dotblas_src) - env.Depends(dotblas, pjoin("blasdot", "cblas.h")) + # because _dotblas does #include CBLAS_HEADER instead of #include + # "cblas.h", scons does not detect the dependency + # XXX: PythonExtension builder does not take the Depends on extension into + # account for some reason, so we first build the object, with forced + # dependency, and then builds the extension. This is more likely a bug in + # our PythonExtension builder, but I cannot see how to solve it. + dotblas_o = env.PythonObject('_dotblas', source = dotblas_src) + env.Depends(dotblas_o, pjoin("blasdot", "cblas.h")) + dotblas = env.DistutilsPythonExtension('_dotblas', dotblas_o) From numpy-svn at scipy.org Wed Jul 9 06:25:34 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 05:25:34 -0500 (CDT) Subject: [Numpy-svn] r5375 - in branches/1.1.x/numpy: core f2py Message-ID: <20080709102534.7A29F39C503@scipy.org> Author: cdavid Date: 2008-07-09 05:25:26 -0500 (Wed, 09 Jul 2008) New Revision: 5375 Modified: branches/1.1.x/numpy/core/SConscript branches/1.1.x/numpy/f2py/setupscons.py Log: More backport from 1.2 for numscons build. Modified: branches/1.1.x/numpy/core/SConscript =================================================================== --- branches/1.1.x/numpy/core/SConscript 2008-07-09 10:23:50 UTC (rev 5374) +++ branches/1.1.x/numpy/core/SConscript 2008-07-09 10:25:26 UTC (rev 5375) @@ -1,4 +1,4 @@ -# Last Change: Thu Jun 12 04:00 PM 2008 J +# Last Change: Sun Jul 06 01:00 PM 2008 J # vim:syntax=python import os import sys @@ -234,7 +234,7 @@ ufunc_api = env.GenerateUfuncApi('ufunc_api', pjoin('code_generators', 'ufunc_api_order.txt')) -env.Append(CPPPATH = ['include', '.']) +env.Prepend(CPPPATH = ['include', '.']) #----------------- # Build multiarray Modified: branches/1.1.x/numpy/f2py/setupscons.py =================================================================== --- branches/1.1.x/numpy/f2py/setupscons.py 2008-07-09 10:23:50 UTC (rev 5374) +++ branches/1.1.x/numpy/f2py/setupscons.py 2008-07-09 10:25:26 UTC (rev 5375) @@ -30,8 +30,6 @@ def configuration(parent_package='',top_path=None): config = Configuration('f2py', parent_package, top_path) - config.add_subpackage('lib') - config.add_data_dir('docs') config.add_data_files('src/fortranobject.c', From numpy-svn at scipy.org Wed Jul 9 06:36:59 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 05:36:59 -0500 (CDT) Subject: [Numpy-svn] r5376 - in branches/1.1.x/numpy: distutils/command fft lib linalg numarray random Message-ID: <20080709103659.CA60239C65A@scipy.org> Author: cdavid Date: 2008-07-09 05:36:41 -0500 (Wed, 09 Jul 2008) New Revision: 5376 Modified: branches/1.1.x/numpy/distutils/command/scons.py branches/1.1.x/numpy/fft/SConscript branches/1.1.x/numpy/lib/SConscript branches/1.1.x/numpy/linalg/SConscript branches/1.1.x/numpy/numarray/SConscript branches/1.1.x/numpy/random/SConscript Log: More backporting of scons changes: require 0.8.2 Modified: branches/1.1.x/numpy/distutils/command/scons.py =================================================================== --- branches/1.1.x/numpy/distutils/command/scons.py 2008-07-09 10:25:26 UTC (rev 5375) +++ branches/1.1.x/numpy/distutils/command/scons.py 2008-07-09 10:36:41 UTC (rev 5376) @@ -338,13 +338,18 @@ "this package " % str(e)) try: + minver = "0.8.2" from numscons import get_version - if get_version() < '0.8.0': + if get_version() < minver: raise ValueError() - except ImportError, ValueError: - raise RuntimeError("You need numscons >= 0.8.0 to build numpy "\ + except ImportError: + raise RuntimeError("You need numscons >= %s to build numpy "\ "with numscons (imported numscons path " \ - "is %s)." % numscons.__file__) + "is %s)." % (minver, numscons.__file__)) + except ValueError: + raise RuntimeError("You need numscons >= %s to build numpy "\ + "with numscons (detected %s )" \ + % (minver, get_version())) else: # nothing to do, just leave it here. Modified: branches/1.1.x/numpy/fft/SConscript =================================================================== --- branches/1.1.x/numpy/fft/SConscript 2008-07-09 10:25:26 UTC (rev 5375) +++ branches/1.1.x/numpy/fft/SConscript 2008-07-09 10:36:41 UTC (rev 5376) @@ -1,10 +1,8 @@ # Last Change: Thu Jun 12 06:00 PM 2008 J # vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths +from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) -fftpack_lite = env.DistutilsPythonExtension('fftpack_lite', - source = ['fftpack_litemodule.c', - 'fftpack.c']) +env.NumpyPythonExtension('fftpack_lite', + source = ['fftpack_litemodule.c', 'fftpack.c']) Modified: branches/1.1.x/numpy/lib/SConscript =================================================================== --- branches/1.1.x/numpy/lib/SConscript 2008-07-09 10:25:26 UTC (rev 5375) +++ branches/1.1.x/numpy/lib/SConscript 2008-07-09 10:36:41 UTC (rev 5376) @@ -1,9 +1,6 @@ # Last Change: Thu Jun 12 06:00 PM 2008 J # vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths +from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) - -_compiled_base = env.DistutilsPythonExtension('_compiled_base', - source = ['src/_compiled_base.c']) +env.NumpyPythonExtension('_compiled_base', source = ['src/_compiled_base.c']) Modified: branches/1.1.x/numpy/linalg/SConscript =================================================================== --- branches/1.1.x/numpy/linalg/SConscript 2008-07-09 10:25:26 UTC (rev 5375) +++ branches/1.1.x/numpy/linalg/SConscript 2008-07-09 10:36:41 UTC (rev 5376) @@ -1,17 +1,12 @@ # Last Change: Thu Jun 12 06:00 PM 2008 J # vim:syntax=python -import os.path - -from numscons import GetNumpyEnvironment, scons_get_paths, \ - scons_get_mathlib +from numscons import GetNumpyEnvironment, scons_get_mathlib from numscons import CheckF77LAPACK from numscons import write_info env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) -config = env.NumpyConfigure(custom_tests = - {'CheckLAPACK' : CheckF77LAPACK}) +config = env.NumpyConfigure(custom_tests = {'CheckLAPACK' : CheckF77LAPACK}) use_lapack = config.CheckLAPACK() @@ -25,5 +20,4 @@ if not use_lapack: sources.extend(['python_xerbla.c', 'zlapack_lite.c', 'dlapack_lite.c', 'blas_lite.c', 'dlamch.c', 'f2c_lite.c']) -lapack_lite = env.DistutilsPythonExtension('lapack_lite', source = sources) - +env.NumpyPythonExtension('lapack_lite', source = sources) Modified: branches/1.1.x/numpy/numarray/SConscript =================================================================== --- branches/1.1.x/numpy/numarray/SConscript 2008-07-09 10:25:26 UTC (rev 5375) +++ branches/1.1.x/numpy/numarray/SConscript 2008-07-09 10:36:41 UTC (rev 5376) @@ -1,9 +1,8 @@ # Last Change: Thu Jun 12 06:00 PM 2008 J # vim:syntax=python -from numscons import GetNumpyEnvironment, scons_get_paths +from numscons import GetNumpyEnvironment env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) env.Append(CPPPATH = ['numpy']) -_capi = env.DistutilsPythonExtension('_capi', source = ['_capi.c']) +env.NumpyPythonExtension('_capi', source = ['_capi.c']) Modified: branches/1.1.x/numpy/random/SConscript =================================================================== --- branches/1.1.x/numpy/random/SConscript 2008-07-09 10:25:26 UTC (rev 5375) +++ branches/1.1.x/numpy/random/SConscript 2008-07-09 10:36:41 UTC (rev 5376) @@ -2,8 +2,7 @@ # vim:syntax=python import os -from numscons import GetNumpyEnvironment, scons_get_paths, \ - scons_get_mathlib +from numscons import GetNumpyEnvironment, scons_get_mathlib def CheckWincrypt(context): from copy import deepcopy @@ -28,7 +27,6 @@ return st[0] env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = scons_get_paths(env['include_bootstrap'])) mlib = scons_get_mathlib(env) env.AppendUnique(LIBS = mlib) @@ -43,4 +41,4 @@ ['mtrand.c', 'randomkit.c', 'initarray.c', 'distributions.c']] # XXX: Pyrex dependency -mtrand = env.DistutilsPythonExtension('mtrand', source = sources) +env.NumpyPythonExtension('mtrand', source = sources) From numpy-svn at scipy.org Wed Jul 9 07:13:42 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 06:13:42 -0500 (CDT) Subject: [Numpy-svn] r5377 - trunk/numpy/lib/tests Message-ID: <20080709111342.C1D3F39C7F0@scipy.org> Author: stefan Date: 2008-07-09 06:13:25 -0500 (Wed, 09 Jul 2008) New Revision: 5377 Modified: trunk/numpy/lib/tests/test_function_base.py Log: Use TestCase instead of NumpyTestCase. Modified: trunk/numpy/lib/tests/test_function_base.py =================================================================== --- trunk/numpy/lib/tests/test_function_base.py 2008-07-09 10:36:41 UTC (rev 5376) +++ trunk/numpy/lib/tests/test_function_base.py 2008-07-09 11:13:25 UTC (rev 5377) @@ -616,7 +616,7 @@ assert(all(unique(x) == [1+1j, 1+10j, 5+6j, 10])) -class TestPiecewise(NumpyTestCase): +class TestPiecewise(TestCase): def check_simple(self): # Condition is single bool list x = piecewise([0, 0], [True, False], [1]) From numpy-svn at scipy.org Wed Jul 9 07:25:01 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 06:25:01 -0500 (CDT) Subject: [Numpy-svn] r5378 - in branches/1.1.x/numpy/core: code_generators src Message-ID: <20080709112501.936B639C089@scipy.org> Author: cdavid Date: 2008-07-09 06:24:45 -0500 (Wed, 09 Jul 2008) New Revision: 5378 Added: branches/1.1.x/numpy/core/code_generators/numpy_api_order.txt Removed: branches/1.1.x/numpy/core/code_generators/array_api_order.txt branches/1.1.x/numpy/core/code_generators/multiarray_api_order.txt Modified: branches/1.1.x/numpy/core/code_generators/generate_array_api.py branches/1.1.x/numpy/core/src/arraymethods.c branches/1.1.x/numpy/core/src/arrayobject.c branches/1.1.x/numpy/core/src/arraytypes.inc.src branches/1.1.x/numpy/core/src/multiarraymodule.c branches/1.1.x/numpy/core/src/scalartypes.inc.src Log: Backport unifed multiarray/object api for code generator. Deleted: branches/1.1.x/numpy/core/code_generators/array_api_order.txt =================================================================== --- branches/1.1.x/numpy/core/code_generators/array_api_order.txt 2008-07-09 11:13:25 UTC (rev 5377) +++ branches/1.1.x/numpy/core/code_generators/array_api_order.txt 2008-07-09 11:24:45 UTC (rev 5378) @@ -1,86 +0,0 @@ -# The functions in the numpy_core C API. They are defined -# here so that the order is set. Do not append to this -# list, append to multiarray_api_order.txt instead. -PyArray_SetNumericOps -PyArray_GetNumericOps -PyArray_INCREF -PyArray_XDECREF -PyArray_SetStringFunction -PyArray_DescrFromType -PyArray_TypeObjectFromType -PyArray_Zero -PyArray_One -PyArray_CastToType -PyArray_CastTo -PyArray_CastAnyTo -PyArray_CanCastSafely -PyArray_CanCastTo -PyArray_ObjectType -PyArray_DescrFromObject -PyArray_ConvertToCommonType -PyArray_DescrFromScalar -PyArray_DescrFromTypeObject -PyArray_Size -PyArray_Scalar -PyArray_FromScalar -PyArray_ScalarAsCtype -PyArray_CastScalarToCtype -PyArray_CastScalarDirect -PyArray_ScalarFromObject -PyArray_GetCastFunc -PyArray_FromDims -PyArray_FromDimsAndDataAndDescr -PyArray_FromAny -PyArray_EnsureArray -PyArray_EnsureAnyArray -PyArray_FromFile -PyArray_FromString -PyArray_FromBuffer -PyArray_FromIter -PyArray_Return -PyArray_GetField -PyArray_SetField -PyArray_Byteswap -PyArray_Resize -PyArray_MoveInto -PyArray_CopyInto -PyArray_CopyAnyInto -PyArray_CopyObject -PyArray_NewCopy -PyArray_ToList -PyArray_ToString -PyArray_ToFile -PyArray_Dump -PyArray_Dumps -PyArray_ValidType -PyArray_UpdateFlags -PyArray_New -PyArray_NewFromDescr -PyArray_DescrNew -PyArray_DescrNewFromType -PyArray_GetPriority -PyArray_IterNew -PyArray_MultiIterNew -PyArray_PyIntAsInt -PyArray_PyIntAsIntp -PyArray_Broadcast -PyArray_FillObjectArray -PyArray_FillWithScalar -PyArray_CheckStrides -PyArray_DescrNewByteorder -PyArray_IterAllButAxis -PyArray_CheckFromAny -PyArray_FromArray -PyArray_FromInterface -PyArray_FromStructInterface -PyArray_FromArrayAttr -PyArray_ScalarKind -PyArray_CanCoerceScalar -PyArray_NewFlagsObject -PyArray_CanCastScalar -PyArray_CompareUCS4 -PyArray_RemoveSmallest -PyArray_ElementStrides -PyArray_Item_INCREF -PyArray_Item_XDECREF -PyArray_FieldNames Modified: branches/1.1.x/numpy/core/code_generators/generate_array_api.py =================================================================== --- branches/1.1.x/numpy/core/code_generators/generate_array_api.py 2008-07-09 11:13:25 UTC (rev 5377) +++ branches/1.1.x/numpy/core/code_generators/generate_array_api.py 2008-07-09 11:24:45 UTC (rev 5378) @@ -118,6 +118,12 @@ }; """ +c_api_header = """ +=========== +Numpy C-API +=========== +""" + def generate_api(output_dir, force=False): basename = 'multiarray_api' @@ -125,7 +131,7 @@ c_file = os.path.join(output_dir, '__%s.c' % basename) d_file = os.path.join(output_dir, '%s.txt' % basename) targets = (h_file, c_file, d_file) - sources = ['array_api_order.txt', 'multiarray_api_order.txt'] + sources = ['numpy_api_order.txt'] if (not force and not genapi.should_rebuild(targets, sources + [__file__])): return targets @@ -139,17 +145,11 @@ c_file = targets[1] doc_file = targets[2] - objectapi_list = genapi.get_api_functions('OBJECT_API', - sources[0]) - multiapi_list = genapi.get_api_functions('MULTIARRAY_API', - sources[1]) - # API fixes for __arrayobject_api.h + numpyapi_list = genapi.get_api_functions('NUMPY_API', sources[0]) + # API fixes for __arrayobject_api.h fixed = 10 numtypes = len(types) + fixed - numobject = len(objectapi_list) + numtypes - nummulti = len(multiapi_list) - numtotal = numobject + nummulti module_list = [] extension_list = [] @@ -167,14 +167,9 @@ extension_list.append(astr) # set up object API - genapi.add_api_list(numtypes, 'PyArray_API', objectapi_list, + genapi.add_api_list(numtypes, 'PyArray_API', numpyapi_list, module_list, extension_list, init_list) - # set up multiarray module API - genapi.add_api_list(numobject, 'PyArray_API', multiapi_list, - module_list, extension_list, init_list) - - # Write to header fid = open(header_file, 'w') s = h_template % ('\n'.join(module_list), '\n'.join(extension_list)) @@ -189,25 +184,10 @@ # write to documentation fid = open(doc_file, 'w') - fid.write(''' -=========== -Numpy C-API -=========== - -Object API -========== -''') - for func in objectapi_list: + fid.write(c_api_header) + for func in numpyapi_list: fid.write(func.to_ReST()) fid.write('\n\n') - fid.write(''' - -Multiarray API -============== -''') - for func in multiapi_list: - fid.write(func.to_ReST()) - fid.write('\n\n') fid.close() return targets Deleted: branches/1.1.x/numpy/core/code_generators/multiarray_api_order.txt =================================================================== --- branches/1.1.x/numpy/core/code_generators/multiarray_api_order.txt 2008-07-09 11:13:25 UTC (rev 5377) +++ branches/1.1.x/numpy/core/code_generators/multiarray_api_order.txt 2008-07-09 11:24:45 UTC (rev 5378) @@ -1,86 +0,0 @@ -PyArray_Transpose -PyArray_TakeFrom -PyArray_PutTo -PyArray_PutMask -PyArray_Repeat -PyArray_Choose -PyArray_Sort -PyArray_ArgSort -PyArray_SearchSorted -PyArray_ArgMax -PyArray_ArgMin -PyArray_Reshape -PyArray_Newshape -PyArray_Squeeze -PyArray_View -PyArray_SwapAxes -PyArray_Max -PyArray_Min -PyArray_Ptp -PyArray_Mean -PyArray_Trace -PyArray_Diagonal -PyArray_Clip -PyArray_Conjugate -PyArray_Nonzero -PyArray_Std -PyArray_Sum -PyArray_CumSum -PyArray_Prod -PyArray_CumProd -PyArray_All -PyArray_Any -PyArray_Compress -PyArray_Flatten -PyArray_Ravel -PyArray_MultiplyList -PyArray_MultiplyIntList -PyArray_GetPtr -PyArray_CompareLists -PyArray_AsCArray -PyArray_As1D -PyArray_As2D -PyArray_Free -PyArray_Converter -PyArray_IntpFromSequence -PyArray_Concatenate -PyArray_InnerProduct -PyArray_MatrixProduct -PyArray_CopyAndTranspose -PyArray_Correlate -PyArray_TypestrConvert -PyArray_DescrConverter -PyArray_DescrConverter2 -PyArray_IntpConverter -PyArray_BufferConverter -PyArray_AxisConverter -PyArray_BoolConverter -PyArray_ByteorderConverter -PyArray_OrderConverter -PyArray_EquivTypes -PyArray_Zeros -PyArray_Empty -PyArray_Where -PyArray_Arange -PyArray_ArangeObj -PyArray_SortkindConverter -PyArray_LexSort -PyArray_Round -PyArray_EquivTypenums -PyArray_RegisterDataType -PyArray_RegisterCastFunc -PyArray_RegisterCanCast -PyArray_InitArrFuncs -PyArray_IntTupleFromIntp -PyArray_TypeNumFromName -PyArray_ClipmodeConverter -PyArray_OutputConverter -PyArray_BroadcastToShape -_PyArray_SigintHandler -_PyArray_GetSigintBuf -PyArray_DescrAlignConverter -PyArray_DescrAlignConverter2 -PyArray_SearchsideConverter -PyArray_CheckAxis -PyArray_OverflowMultiplyList -PyArray_CompareString Copied: branches/1.1.x/numpy/core/code_generators/numpy_api_order.txt (from rev 5229, trunk/numpy/core/code_generators/numpy_api_order.txt) Modified: branches/1.1.x/numpy/core/src/arraymethods.c =================================================================== --- branches/1.1.x/numpy/core/src/arraymethods.c 2008-07-09 11:13:25 UTC (rev 5377) +++ branches/1.1.x/numpy/core/src/arraymethods.c 2008-07-09 11:24:45 UTC (rev 5378) @@ -246,7 +246,7 @@ /* steals typed reference */ -/*OBJECT_API +/*NUMPY_API Get a subset of bytes from each element of the array */ static PyObject * @@ -295,7 +295,7 @@ } -/*OBJECT_API +/*NUMPY_API Set a subset of bytes from each element of the array */ static int @@ -351,7 +351,7 @@ /* This doesn't change the descriptor just the actual data... */ -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_Byteswap(PyArrayObject *self, Bool inplace) { @@ -1351,7 +1351,7 @@ return Py_None; } -/*OBJECT_API*/ +/*NUMPY_API*/ static int PyArray_Dump(PyObject *self, PyObject *file, int protocol) { @@ -1376,7 +1376,7 @@ return 0; } -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_Dumps(PyObject *self, int protocol) { Modified: branches/1.1.x/numpy/core/src/arrayobject.c =================================================================== --- branches/1.1.x/numpy/core/src/arrayobject.c 2008-07-09 11:13:25 UTC (rev 5377) +++ branches/1.1.x/numpy/core/src/arrayobject.c 2008-07-09 11:24:45 UTC (rev 5378) @@ -21,7 +21,7 @@ */ /*#include */ -/*OBJECT_API +/*NUMPY_API * Get Priority from object */ static double @@ -68,7 +68,7 @@ */ -/*OBJECT_API +/*NUMPY_API Get pointer to zero of correct type for array. */ static char * @@ -103,7 +103,7 @@ return zeroval; } -/*OBJECT_API +/*NUMPY_API Get pointer to one of correct type for array */ static char * @@ -149,7 +149,7 @@ /* Incref all objects found at this record */ -/*OBJECT_API +/*NUMPY_API */ static void PyArray_Item_INCREF(char *data, PyArray_Descr *descr) @@ -181,7 +181,7 @@ } /* XDECREF all objects found at this record */ -/*OBJECT_API +/*NUMPY_API */ static void PyArray_Item_XDECREF(char *data, PyArray_Descr *descr) @@ -216,7 +216,7 @@ /* Used for arrays of python objects to increment the reference count of */ /* every python object in the array. */ -/*OBJECT_API +/*NUMPY_API For object arrays, increment all internal references. */ static int @@ -272,7 +272,7 @@ return 0; } -/*OBJECT_API +/*NUMPY_API Decrement all internal references for object arrays. (or arrays with object fields) */ @@ -535,7 +535,7 @@ /* Helper functions */ -/*OBJECT_API*/ +/*NUMPY_API*/ static intp PyArray_PyIntAsIntp(PyObject *o) { @@ -635,7 +635,7 @@ static PyObject *array_int(PyArrayObject *v); -/*OBJECT_API*/ +/*NUMPY_API*/ static int PyArray_PyIntAsInt(PyObject *o) { @@ -745,7 +745,7 @@ return NULL; } -/*OBJECT_API +/*NUMPY_API Compute the size of an array (in number of items) */ static intp @@ -1137,7 +1137,7 @@ } } -/*OBJECT_API +/*NUMPY_API * Copy an Array into another array -- memory must not overlap * Does not require src and dest to have "broadcastable" shapes * (only the same number of elements). @@ -1216,7 +1216,7 @@ return 0; } -/*OBJECT_API +/*NUMPY_API * Copy an Array into another array -- memory must not overlap. */ static int @@ -1226,7 +1226,7 @@ } -/*OBJECT_API +/*NUMPY_API * Move the memory of one array into another. */ static int @@ -1236,7 +1236,7 @@ } -/*OBJECT_API*/ +/*NUMPY_API*/ static int PyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) { @@ -1300,7 +1300,7 @@ /* They all zero-out the memory as previously done */ /* steals reference to descr -- and enforces native byteorder on it.*/ -/*OBJECT_API +/*NUMPY_API Like FromDimsAndData but uses the Descr structure instead of typecode as input. */ @@ -1333,7 +1333,7 @@ return ret; } -/*OBJECT_API +/*NUMPY_API Construct an empty array from dimensions and typenum */ static PyObject * @@ -1356,7 +1356,7 @@ /* end old calls */ -/*OBJECT_API +/*NUMPY_API Copy an array. */ static PyObject * @@ -1388,7 +1388,7 @@ static PyObject *array_big_item(PyArrayObject *, intp); /* Does nothing with descr (cannot be NULL) */ -/*OBJECT_API +/*NUMPY_API Get scalar-equivalent to a region of memory described by a descriptor. */ static PyObject * @@ -1542,7 +1542,7 @@ /* Return Array Scalar if 0-d array object is encountered */ -/*OBJECT_API +/*NUMPY_API Return either an array or the appropriate Python object if the array is 0d and matches a Python type. */ @@ -1572,7 +1572,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Initialize arrfuncs to NULL */ static void @@ -1643,7 +1643,7 @@ found. Only works for user-defined data-types. */ -/*MULTIARRAY_API +/*NUMPY_API */ static int PyArray_TypeNumFromName(char *str) @@ -1665,7 +1665,7 @@ needs the userdecrs table and PyArray_NUMUSER variables defined in arraytypes.inc */ -/*MULTIARRAY_API +/*NUMPY_API Register Data type Does not change the reference count of descr */ @@ -1717,7 +1717,7 @@ return typenum; } -/*MULTIARRAY_API +/*NUMPY_API Register Casting Function Replaces any function currently stored. */ @@ -1762,7 +1762,7 @@ return newtypes; } -/*MULTIARRAY_API +/*NUMPY_API Register a type number indicating that a descriptor can be cast to it safely */ @@ -1811,7 +1811,7 @@ This will need the addition of a Fortran-order iterator. */ -/*OBJECT_API +/*NUMPY_API To File */ static int @@ -1952,7 +1952,7 @@ return 0; } -/*OBJECT_API +/*NUMPY_API * To List */ static PyObject * @@ -1987,7 +1987,7 @@ return lp; } -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_ToString(PyArrayObject *self, NPY_ORDER order) { @@ -3365,7 +3365,7 @@ } -/*OBJECT_API +/*NUMPY_API Set internal structure with number functions that all arrays will use */ int @@ -3413,7 +3413,7 @@ (PyDict_SetItemString(dict, #op, n_ops.op)==-1)) \ goto fail; -/*OBJECT_API +/*NUMPY_API Get dictionary showing number functions that all arrays will use */ static PyObject * @@ -4362,7 +4362,7 @@ static PyObject *PyArray_StrFunction=NULL; static PyObject *PyArray_ReprFunction=NULL; -/*OBJECT_API +/*NUMPY_API Set the array print function to be a Python function. */ static void @@ -4417,7 +4417,7 @@ -/*OBJECT_API +/*NUMPY_API */ static int PyArray_CompareUCS4(npy_ucs4 *s1, npy_ucs4 *s2, register size_t len) @@ -4433,7 +4433,7 @@ return 0; } -/*MULTIARRAY_API +/*NUMPY_API */ static int PyArray_CompareString(char *s1, char *s2, size_t len) @@ -5028,7 +5028,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API PyArray_CheckAxis */ static PyObject * @@ -5079,7 +5079,7 @@ #include "arraymethods.c" /* Lifted from numarray */ -/*MULTIARRAY_API +/*NUMPY_API PyArray_IntTupleFromIntp */ static PyObject * @@ -5107,7 +5107,7 @@ /* Returns the number of dimensions or -1 if an error occurred */ /* vals must be large enough to hold maxvals */ -/*MULTIARRAY_API +/*NUMPY_API PyArray_IntpFromSequence */ static int @@ -5255,7 +5255,7 @@ } -/*OBJECT_API +/*NUMPY_API */ static int PyArray_ElementStrides(PyObject *arr) @@ -5271,7 +5271,7 @@ return 1; } -/*OBJECT_API +/*NUMPY_API Update Several Flags at once. */ static void @@ -5321,7 +5321,7 @@ or negative). */ -/*OBJECT_API*/ +/*NUMPY_API*/ static Bool PyArray_CheckStrides(int elsize, int nd, intp numbytes, intp offset, intp *dims, intp *newstrides) @@ -5389,7 +5389,7 @@ return itemsize; } -/*OBJECT_API +/*NUMPY_API Generic new array creation routine. */ static PyObject * @@ -5492,7 +5492,7 @@ /* steals a reference to descr (even on failure) */ -/*OBJECT_API +/*NUMPY_API Generic new array creation routine. */ static PyObject * @@ -5718,7 +5718,7 @@ } -/*OBJECT_API +/*NUMPY_API Resize (reallocate data). Only works if nothing else is referencing this array and it is contiguous. If refcheck is 0, then the reference count is not checked @@ -5888,7 +5888,7 @@ } /* Assumes contiguous */ -/*OBJECT_API*/ +/*NUMPY_API*/ static void PyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj) { @@ -5920,7 +5920,7 @@ } } -/*OBJECT_API*/ +/*NUMPY_API*/ static int PyArray_FillWithScalar(PyArrayObject *arr, PyObject *obj) { @@ -7738,7 +7738,7 @@ } -/*OBJECT_API +/*NUMPY_API Is the typenum valid? */ static int @@ -7758,7 +7758,7 @@ /* For backward compatibility */ /* steals reference to at --- cannot be NULL*/ -/*OBJECT_API +/*NUMPY_API *Cast an array using typecode structure. */ static PyObject * @@ -7819,7 +7819,7 @@ } -/*OBJECT_API +/*NUMPY_API Get a cast function to cast from the input descriptor to the output type_number (must be a registered data-type). Returns NULL if un-successful. @@ -8017,7 +8017,7 @@ * as the size of the casting buffer. */ -/*OBJECT_API +/*NUMPY_API * Cast to an already created array. */ static int @@ -8181,7 +8181,7 @@ return retval; } -/*OBJECT_API +/*NUMPY_API Cast to an already created array. Arrays don't have to be "broadcastable" Only requirement is they have the same number of elements. */ @@ -8231,7 +8231,7 @@ /* steals reference to newtype --- acc. NULL */ -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) { @@ -8489,7 +8489,7 @@ return descr; } -/*OBJECT_API */ +/*NUMPY_API */ static PyObject * PyArray_FromStructInterface(PyObject *input) { @@ -8545,7 +8545,7 @@ #define PyIntOrLong_Check(obj) (PyInt_Check(obj) || PyLong_Check(obj)) -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_FromInterface(PyObject *input) { @@ -8696,7 +8696,7 @@ return NULL; } -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_FromArrayAttr(PyObject *op, PyArray_Descr *typecode, PyObject *context) { @@ -8745,7 +8745,7 @@ /* Does not check for ENSURECOPY and NOTSWAPPED in flags */ /* Steals a reference to newtype --- which can be NULL */ -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth, int max_depth, int flags, PyObject *context) @@ -8873,14 +8873,14 @@ } /* new reference -- accepts NULL for mintype*/ -/*OBJECT_API*/ +/*NUMPY_API*/ static PyArray_Descr * PyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype) { return _array_find_type(op, mintype, MAX_DIMS); } -/*OBJECT_API +/*NUMPY_API Return the typecode of the array a Python object would be converted to */ @@ -8943,7 +8943,7 @@ /* steals a reference to descr -- accepts NULL */ -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int min_depth, int max_depth, int requires, PyObject *context) @@ -8984,7 +8984,7 @@ /* Because it decrefs op if any conversion needs to take place so it can be used like PyArray_EnsureArray(some_function(...)) */ -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_EnsureArray(PyObject *op) { @@ -9009,7 +9009,7 @@ return new; } -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_EnsureAnyArray(PyObject *op) { @@ -9017,7 +9017,7 @@ return PyArray_EnsureArray(op); } -/*OBJECT_API +/*NUMPY_API Check the type coercion rules. */ static int @@ -9124,7 +9124,7 @@ } /* leaves reference count alone --- cannot be NULL*/ -/*OBJECT_API*/ +/*NUMPY_API*/ static Bool PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to) { @@ -9156,7 +9156,7 @@ return ret; } -/*OBJECT_API +/*NUMPY_API See if array scalars can be cast. */ static Bool @@ -9177,7 +9177,7 @@ /* Aided by Peter J. Verveer's nd_image package and numpy's arraymap ****/ /* and Python's array iterator ***/ -/*OBJECT_API +/*NUMPY_API Get Iterator. */ static PyObject * @@ -9221,7 +9221,7 @@ return (PyObject *)it; } -/*MULTIARRAY_API +/*NUMPY_API Get Iterator broadcast to a particular shape */ static PyObject * @@ -9288,7 +9288,7 @@ -/*OBJECT_API +/*NUMPY_API Get Iterator that iterates over all but one axis (don't use this with PyArray_ITER_GOTO1D). The axis will be over-written if negative with the axis having the smallest stride. @@ -9338,7 +9338,7 @@ /* don't use with PyArray_ITER_GOTO1D because factors are not adjusted */ -/*OBJECT_API +/*NUMPY_API Adjusts previously broadcasted iterators so that the axis with the smallest sum of iterator strides is not iterated over. Returns dimension which is smallest in the range [0,multi->nd). @@ -10119,7 +10119,7 @@ /* Adjust dimensionality and strides for index object iterators --- i.e. broadcast */ -/*OBJECT_API*/ +/*NUMPY_API*/ static int PyArray_Broadcast(PyArrayMultiIterObject *mit) { @@ -10761,7 +10761,7 @@ /** END of Subscript Iterator **/ -/*OBJECT_API +/*NUMPY_API Get MultiIterator, */ static PyObject * @@ -11033,7 +11033,7 @@ 0 /* tp_weaklist */ }; -/*OBJECT_API*/ +/*NUMPY_API*/ static PyArray_Descr * PyArray_DescrNewFromType(int type_num) { @@ -11060,7 +11060,7 @@ **/ /* base cannot be NULL */ -/*OBJECT_API*/ +/*NUMPY_API*/ static PyArray_Descr * PyArray_DescrNew(PyArray_Descr *base) { @@ -11701,7 +11701,7 @@ byte-order is not changed but any fields are: */ -/*OBJECT_API +/*NUMPY_API Deep bytorder change of a data-type descriptor *** Leaves reference count of self unchanged --- does not DECREF self *** */ @@ -12088,7 +12088,7 @@ /** Array Flags Object **/ -/*OBJECT_API +/*NUMPY_API Get New ArrayFlagsObject */ static PyObject * Modified: branches/1.1.x/numpy/core/src/arraytypes.inc.src =================================================================== --- branches/1.1.x/numpy/core/src/arraytypes.inc.src 2008-07-09 11:13:25 UTC (rev 5377) +++ branches/1.1.x/numpy/core/src/arraytypes.inc.src 2008-07-09 11:24:45 UTC (rev 5378) @@ -2470,7 +2470,7 @@ &VOID_Descr, }; -/*OBJECT_API +/*NUMPY_API Get the PyArray_Descr structure for a type. */ static PyArray_Descr * Modified: branches/1.1.x/numpy/core/src/multiarraymodule.c =================================================================== --- branches/1.1.x/numpy/core/src/multiarraymodule.c 2008-07-09 11:13:25 UTC (rev 5377) +++ branches/1.1.x/numpy/core/src/multiarraymodule.c 2008-07-09 11:24:45 UTC (rev 5378) @@ -100,7 +100,7 @@ /* An Error object -- rarely used? */ static PyObject *MultiArrayError; -/*MULTIARRAY_API +/*NUMPY_API Multiply a List of ints */ static int @@ -111,7 +111,7 @@ return s; } -/*MULTIARRAY_API +/*NUMPY_API Multiply a List */ static intp @@ -122,7 +122,7 @@ return s; } -/*MULTIARRAY_API +/*NUMPY_API Multiply a List of Non-negative numbers with over-flow detection. */ static intp @@ -138,7 +138,7 @@ return s; } -/*MULTIARRAY_API +/*NUMPY_API Produce a pointer into array */ static void * @@ -152,7 +152,7 @@ return (void *)dptr; } -/*MULTIARRAY_API +/*NUMPY_API Get axis from an object (possibly None) -- a converter function, */ static int @@ -170,7 +170,7 @@ return PY_SUCCEED; } -/*MULTIARRAY_API +/*NUMPY_API Compare Lists */ static int @@ -184,7 +184,7 @@ } /* steals a reference to type -- accepts NULL */ -/*MULTIARRAY_API +/*NUMPY_API View */ static PyObject * @@ -222,7 +222,7 @@ /* Returns a contiguous array */ -/*MULTIARRAY_API +/*NUMPY_API Ravel */ static PyObject * @@ -260,7 +260,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Round */ static PyObject * @@ -382,7 +382,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Flatten */ static PyObject * @@ -416,7 +416,7 @@ / * Not recommended */ -/*MULTIARRAY_API +/*NUMPY_API Reshape an array */ static PyObject * @@ -624,7 +624,7 @@ copy-only-if-necessary */ -/*MULTIARRAY_API +/*NUMPY_API New shape for an array */ static PyObject * @@ -771,7 +771,7 @@ return the same array. */ -/*MULTIARRAY_API*/ +/*NUMPY_API*/ static PyObject * PyArray_Squeeze(PyArrayObject *self) { @@ -811,7 +811,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Mean */ static PyObject * @@ -843,7 +843,7 @@ } /* Set variance to 1 to by-pass square-root calculation and return variance */ -/*MULTIARRAY_API +/*NUMPY_API Std */ static PyObject * @@ -962,7 +962,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Sum */ static PyObject * @@ -978,7 +978,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Prod */ static PyObject * @@ -994,7 +994,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API CumSum */ static PyObject * @@ -1010,7 +1010,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API CumProd */ static PyObject * @@ -1027,7 +1027,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Any */ static PyObject * @@ -1044,7 +1044,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API All */ static PyObject * @@ -1062,7 +1062,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Compress */ static PyObject * @@ -1091,7 +1091,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Nonzero */ static PyObject * @@ -1188,7 +1188,7 @@ return res2; } -/*MULTIARRAY_API +/*NUMPY_API Clip */ static PyObject * @@ -1417,7 +1417,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Conjugate */ static PyObject * @@ -1447,7 +1447,7 @@ } } -/*MULTIARRAY_API +/*NUMPY_API Trace */ static PyObject * @@ -1463,7 +1463,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Diagonal */ static PyObject * @@ -1598,7 +1598,7 @@ */ /* steals a reference to typedescr -- can be NULL*/ -/*MULTIARRAY_API +/*NUMPY_API Simulat a C-array */ static int @@ -1657,7 +1657,7 @@ /* Deprecated --- Use PyArray_AsCArray instead */ -/*MULTIARRAY_API +/*NUMPY_API Convert to a 1D C-array */ static int @@ -1673,7 +1673,7 @@ return 0; } -/*MULTIARRAY_API +/*NUMPY_API Convert to a 2D C-array */ static int @@ -1693,7 +1693,7 @@ /* End Deprecated */ -/*MULTIARRAY_API +/*NUMPY_API Free pointers created if As2D is called */ static int @@ -1748,7 +1748,7 @@ /* If axis is MAX_DIMS or bigger, then each sequence object will be flattened before concatenation */ -/*MULTIARRAY_API +/*NUMPY_API Concatenate an arbitrary Python sequence into an array. */ static PyObject * @@ -1859,7 +1859,7 @@ return NULL; } -/*MULTIARRAY_API +/*NUMPY_API SwapAxes */ static PyObject * @@ -1906,7 +1906,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Return Transpose. */ static PyObject * @@ -1978,7 +1978,7 @@ return (PyObject *)ret; } -/*MULTIARRAY_API +/*NUMPY_API Repeat the array. */ static PyObject * @@ -2101,7 +2101,7 @@ } -/*OBJECT_API*/ +/*NUMPY_API*/ static NPY_SCALARKIND PyArray_ScalarKind(int typenum, PyArrayObject **arr) { @@ -2128,7 +2128,7 @@ return PyArray_OBJECT_SCALAR; } -/*OBJECT_API*/ +/*NUMPY_API*/ static int PyArray_CanCoerceScalar(int thistype, int neededtype, NPY_SCALARKIND scalar) @@ -2168,7 +2168,7 @@ } -/*OBJECT_API*/ +/*NUMPY_API*/ static PyArrayObject ** PyArray_ConvertToCommonType(PyObject *op, int *retn) { @@ -2284,7 +2284,7 @@ return NULL; } -/*MULTIARRAY_API +/*NUMPY_API */ static PyObject * PyArray_Choose(PyArrayObject *ip, PyObject *op, PyArrayObject *ret, @@ -2645,7 +2645,7 @@ } \ } -/*MULTIARRAY_API +/*NUMPY_API Sort an array in-place */ static int @@ -2731,7 +2731,7 @@ global_obj); } -/*MULTIARRAY_API +/*NUMPY_API ArgSort an array */ static PyObject * @@ -2821,7 +2821,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API LexSort an array providing indices that will sort a collection of arrays lexicographically. The first key is sorted on first, followed by the second key -- requires that arg"merge"sort is available for each sort_key @@ -3086,7 +3086,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Convert object to searchsorted side */ static int @@ -3114,7 +3114,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Numeric.searchsorted(a,v) */ static PyObject * @@ -3214,7 +3214,7 @@ /* Could perhaps be redone to not make contiguous arrays */ -/*MULTIARRAY_API +/*NUMPY_API Numeric.innerproduct(a,v) */ static PyObject * @@ -3326,7 +3326,7 @@ /* just like inner product but does the swapaxes stuff on the fly */ -/*MULTIARRAY_API +/*NUMPY_API Numeric.matrixproduct(a,v) */ static PyObject * @@ -3458,7 +3458,7 @@ return NULL; } -/*MULTIARRAY_API +/*NUMPY_API Fast Copy and Transpose */ static PyObject * @@ -3521,7 +3521,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Numeric.correlate(a1,a2,mode) */ static PyObject * @@ -3631,7 +3631,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API ArgMin */ static PyObject * @@ -3661,7 +3661,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Max */ static PyObject * @@ -3678,7 +3678,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Min */ static PyObject * @@ -3695,7 +3695,7 @@ return ret; } -/*MULTIARRAY_API +/*NUMPY_API Ptp */ static PyObject * @@ -3730,7 +3730,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API ArgMax */ static PyObject * @@ -3839,7 +3839,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Take */ static PyObject * @@ -4001,7 +4001,7 @@ return NULL; } -/*MULTIARRAY_API +/*NUMPY_API Put values into an array */ static PyObject * @@ -4167,7 +4167,7 @@ return PyArray_PutMask((PyArrayObject *)array, values, mask); } -/*MULTIARRAY_API +/*NUMPY_API Put values into an array according to a mask. */ static PyObject * @@ -4276,7 +4276,7 @@ as you get a new reference to it. */ -/*MULTIARRAY_API +/*NUMPY_API Useful to pass as converter function for O& processing in PyArgs_ParseTuple. */ @@ -4295,7 +4295,7 @@ } } -/*MULTIARRAY_API +/*NUMPY_API Useful to pass as converter function for O& processing in PyArgs_ParseTuple for output arrays */ @@ -4319,7 +4319,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Convert an object to true / false */ static int @@ -4333,7 +4333,7 @@ return PY_SUCCEED; } -/*MULTIARRAY_API +/*NUMPY_API Convert an object to FORTRAN / C / ANY */ static int @@ -4372,7 +4372,7 @@ return PY_SUCCEED; } -/*MULTIARRAY_API +/*NUMPY_API Convert an object to NPY_RAISE / NPY_CLIP / NPY_WRAP */ static int @@ -4418,7 +4418,7 @@ -/*MULTIARRAY_API +/*NUMPY_API Typestr converter */ static int @@ -4551,7 +4551,7 @@ */ -/*MULTIARRAY_API +/*NUMPY_API Get buffer chunk from object */ static int @@ -4591,7 +4591,7 @@ PyDimMem_FREE(seq.ptr)** */ -/*MULTIARRAY_API +/*NUMPY_API Get intp chunk from sequence */ static int @@ -5238,7 +5238,7 @@ */ -/*MULTIARRAY_API +/*NUMPY_API Get type-descriptor from an object forcing alignment if possible None goes to DEFAULT type. */ @@ -5267,7 +5267,7 @@ return PY_SUCCEED; } -/*MULTIARRAY_API +/*NUMPY_API Get type-descriptor from an object forcing alignment if possible None goes to NULL. */ @@ -5297,7 +5297,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Get typenum from an object -- None goes to NULL */ static int @@ -5321,7 +5321,7 @@ */ /* new reference in *at */ -/*MULTIARRAY_API +/*NUMPY_API Get typenum from an object -- None goes to PyArray_DEFAULT */ static int @@ -5505,7 +5505,7 @@ return PY_FAIL; } -/*MULTIARRAY_API +/*NUMPY_API Convert object to endian */ static int @@ -5543,7 +5543,7 @@ return PY_SUCCEED; } -/*MULTIARRAY_API +/*NUMPY_API Convert object to sort kind */ static int @@ -5596,7 +5596,7 @@ equivalent (same basic kind and same itemsize). */ -/*MULTIARRAY_API*/ +/*NUMPY_API*/ static unsigned char PyArray_EquivTypes(PyArray_Descr *typ1, PyArray_Descr *typ2) { @@ -5618,7 +5618,7 @@ return (typ1->kind == typ2->kind); } -/*MULTIARRAY_API*/ +/*NUMPY_API*/ static unsigned char PyArray_EquivTypenums(int typenum1, int typenum2) { @@ -5768,7 +5768,7 @@ /* accepts NULL type */ /* steals referenct to type */ -/*MULTIARRAY_API +/*NUMPY_API Empty */ static PyObject * @@ -5889,7 +5889,7 @@ /* steal a reference */ /* accepts NULL type */ -/*MULTIARRAY_API +/*NUMPY_API Zeros */ static PyObject * @@ -6172,7 +6172,7 @@ } #undef FROM_BUFFER_SIZE -/*OBJECT_API +/*NUMPY_API Given a pointer to a string ``data``, a string length ``slen``, and a ``PyArray_Descr``, return an array corresponding to the data @@ -6332,7 +6332,7 @@ return r; } -/*OBJECT_API +/*NUMPY_API Given a ``FILE *`` pointer ``fp``, and a ``PyArray_Descr``, return an array corresponding to the data encoded in that file. @@ -6452,7 +6452,7 @@ /* steals a reference to dtype (which cannot be NULL) */ -/*OBJECT_API */ +/*NUMPY_API */ static PyObject * PyArray_FromIter(PyObject *obj, PyArray_Descr *dtype, intp count) { @@ -6567,7 +6567,7 @@ } -/*OBJECT_API*/ +/*NUMPY_API*/ static PyObject * PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, intp count, intp offset) @@ -6737,7 +6737,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Arange, */ static PyObject * @@ -6841,7 +6841,7 @@ } /* this doesn't change the references */ -/*MULTIARRAY_API +/*NUMPY_API ArangeObj, */ static PyObject * @@ -7065,7 +7065,7 @@ } -/*MULTIARRAY_API +/*NUMPY_API Where */ static PyObject * @@ -7373,7 +7373,7 @@ SIGJMP_BUF _NPY_SIGINT_BUF; -/*MULTIARRAY_API +/*NUMPY_API */ static void _PyArray_SigintHandler(int signum) @@ -7382,7 +7382,7 @@ SIGLONGJMP(_NPY_SIGINT_BUF, signum); } -/*MULTIARRAY_API +/*NUMPY_API */ static void* _PyArray_GetSigintBuf(void) Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src =================================================================== --- branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-09 11:13:25 UTC (rev 5377) +++ branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-09 11:24:45 UTC (rev 5378) @@ -131,7 +131,7 @@ /* no error checking is performed -- ctypeptr must be same type as scalar */ /* in case of flexible type, the data is not copied into ctypeptr which is expected to be a pointer to pointer */ -/*OBJECT_API +/*NUMPY_API Convert to c-type */ static void @@ -160,7 +160,7 @@ /* This may not work right on narrow builds for NumPy unicode scalars. */ -/*OBJECT_API +/*NUMPY_API Cast Scalar to c-type */ static int @@ -197,7 +197,7 @@ return 0; } -/*OBJECT_API +/*NUMPY_API Cast Scalar to c-type */ static int @@ -220,7 +220,7 @@ */ /* steals reference to outcode */ -/*OBJECT_API +/*NUMPY_API Get 0-dim array from scalar */ static PyObject * @@ -292,7 +292,7 @@ return ret; } -/*OBJECT_API +/*NUMPY_API Get an Array Scalar From a Python Object Returns NULL if unsuccessful but error is only set if another error occurred. Currently only Numeric-like @@ -2720,7 +2720,7 @@ } /*New reference */ -/*OBJECT_API +/*NUMPY_API */ static PyArray_Descr * PyArray_DescrFromTypeObject(PyObject *type) @@ -2785,7 +2785,7 @@ return _descr_from_subtype(type); } -/*OBJECT_API +/*NUMPY_API Return the tuple of ordered field names from a dictionary. */ static PyObject * @@ -2812,7 +2812,7 @@ } /* New reference */ -/*OBJECT_API +/*NUMPY_API Return descr object from array scalar. */ static PyArray_Descr * @@ -2856,7 +2856,7 @@ } /* New reference */ -/*OBJECT_API +/*NUMPY_API Get a typeobject from a type-number -- can return NULL. */ static PyObject * From numpy-svn at scipy.org Wed Jul 9 16:07:31 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 15:07:31 -0500 (CDT) Subject: [Numpy-svn] r5379 - trunk/numpy/testing Message-ID: <20080709200731.D8CC039C2F8@scipy.org> Author: alan.mcintyre Date: 2008-07-09 15:07:25 -0500 (Wed, 09 Jul 2008) New Revision: 5379 Modified: trunk/numpy/testing/nosetester.py Log: Updated doctest for NoseTester to reflect actual usage, and added __file__ = '__main__' to doctest context to allow the updated test to run correctly. Added setupscons.py and setup.py to the list of files to ignore when looking for doctests. Cleaned up docstrings for readability. Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-09 11:24:45 UTC (rev 5378) +++ trunk/numpy/testing/nosetester.py 2008-07-09 20:07:25 UTC (rev 5379) @@ -89,7 +89,12 @@ # Each doctest should execute in an environment equivalent to # starting Python and executing "import numpy as np" + # + # Note: __file__ allows the doctest in NoseTester to run + # without producing an error test.globs = {'__builtins__':__builtins__, + '__file__':'__main__', + '__name__':'__main__', 'np':numpy} # always use whitespace and ellipsis options @@ -112,7 +117,8 @@ # so that we can ignore NumPy-specific build files that shouldn't # be searched for tests old_wantFile = npd.Doctest.wantFile - ignore_files = ['generate_numpy_api.py', 'scons_support.py'] + ignore_files = ['generate_numpy_api.py', 'scons_support.py', + 'setupscons.py', 'setup.py'] def wantFile(self, file): bn = os.path.basename(file) if bn in ignore_files: @@ -161,16 +167,17 @@ Usage: NoseTester().test() is package path or module Default for package is None. A - value of None finds calling module path. + value of None finds the calling module path. - Typical call is from module __init__, and corresponds to this: + This class is made available as numpy.testing.Tester, and a test function + is typically added to a package's __init__.py like so: - >>> test = NoseTester().test + >>> from numpy.testing import Tester + >>> test = Tester().test - This class is made available as numpy.testing.Tester: + Calling this test function finds and runs all tests associated with the + package and all its subpackages. - >>> from numpy.testing import Tester - >>> test = Tester().test """ def __init__(self, package=None): From numpy-svn at scipy.org Wed Jul 9 16:19:58 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 15:19:58 -0500 (CDT) Subject: [Numpy-svn] r5380 - trunk/numpy/core/tests Message-ID: <20080709201958.5679B39C50D@scipy.org> Author: alan.mcintyre Date: 2008-07-09 15:19:55 -0500 (Wed, 09 Jul 2008) New Revision: 5380 Modified: trunk/numpy/core/tests/test_defmatrix.py Log: Test coverage improvements. Modified: trunk/numpy/core/tests/test_defmatrix.py =================================================================== --- trunk/numpy/core/tests/test_defmatrix.py 2008-07-09 20:07:25 UTC (rev 5379) +++ trunk/numpy/core/tests/test_defmatrix.py 2008-07-09 20:19:55 UTC (rev 5380) @@ -1,4 +1,3 @@ -import sys from numpy.testing import * from numpy.core import * import numpy as np @@ -91,6 +90,9 @@ assert A.sum() == matrix(2) assert A.mean() == matrix(0.5) + def test_repr(self): + A = matrix([[1,0],[0,1]]) + assert repr(A) == "matrix([[1, 0],\n [0, 1]])" class TestCasting(TestCase): def test_basic(self): @@ -134,7 +136,32 @@ assert allclose((mA + mA).A, (A + A)) assert allclose((3*mA).A, (3*A)) + mA2 = matrix(A) + mA2 *= 3 + assert allclose(mA2.A, 3*A) + + def test_notimplemented(self): + '''Check that 'not implemented' operations produce a failure.''' + A = matrix([[1., 2.], + [3., 4.]]) + # __rpow__ + try: + 1.0**A + except TypeError: + pass + else: + self.fail("matrix.__rpow__ doesn't raise a TypeError") + + # __mul__ with something not a list, ndarray, tuple, or scalar + try: + A*object() + except TypeError: + pass + else: + self.fail("matrix.__mul__ with non-numeric object doesn't raise" + "a TypeError") + class TestMatrixReturn(TestCase): def test_instance_methods(self): a = matrix([1.0], dtype='f8') From numpy-svn at scipy.org Wed Jul 9 16:25:46 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 15:25:46 -0500 (CDT) Subject: [Numpy-svn] r5381 - trunk/numpy/core Message-ID: <20080709202546.08CA539C59C@scipy.org> Author: alan.mcintyre Date: 2008-07-09 15:25:41 -0500 (Wed, 09 Jul 2008) New Revision: 5381 Modified: trunk/numpy/core/defmatrix.py Log: Removed matrix._get_truendim (unused). Modified: trunk/numpy/core/defmatrix.py =================================================================== --- trunk/numpy/core/defmatrix.py 2008-07-09 20:19:55 UTC (rev 5380) +++ trunk/numpy/core/defmatrix.py 2008-07-09 20:25:41 UTC (rev 5381) @@ -249,13 +249,6 @@ out.shape = (1,sh) return out - def _get_truendim(self): - shp = self.shape - truend = 0 - for val in shp: - if (val > 1): truend += 1 - return truend - def __mul__(self, other): if isinstance(other,(N.ndarray, list, tuple)) : # This promotes 1-D vectors to row vectors From numpy-svn at scipy.org Wed Jul 9 16:49:47 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 15:49:47 -0500 (CDT) Subject: [Numpy-svn] r5382 - trunk/numpy/lib Message-ID: <20080709204947.856CB39C0B9@scipy.org> Author: alan.mcintyre Date: 2008-07-09 15:49:40 -0500 (Wed, 09 Jul 2008) New Revision: 5382 Modified: trunk/numpy/lib/index_tricks.py trunk/numpy/lib/scimath.py Log: Make doctests pass under new execution context. Modified: trunk/numpy/lib/index_tricks.py =================================================================== --- trunk/numpy/lib/index_tricks.py 2008-07-09 20:25:41 UTC (rev 5381) +++ trunk/numpy/lib/index_tricks.py 2008-07-09 20:49:40 UTC (rev 5382) @@ -102,7 +102,7 @@ Examples -------- - >>> mgrid = nd_grid() + >>> mgrid = np.nd_grid() >>> mgrid[0:5,0:5] array([[[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], @@ -319,7 +319,7 @@ """Translates slice objects to concatenation along the first axis. For example: - >>> r_[array([1,2,3]), 0, 0, array([4,5,6])] + >>> np.r_[array([1,2,3]), 0, 0, array([4,5,6])] array([1, 2, 3, 0, 0, 4, 5, 6]) """ @@ -332,7 +332,7 @@ """Translates slice objects to concatenation along the second axis. For example: - >>> c_[array([[1,2,3]]), 0, 0, array([[4,5,6]])] + >>> np.c_[array([[1,2,3]]), 0, 0, array([[4,5,6]])] array([1, 2, 3, 0, 0, 4, 5, 6]) """ def __init__(self): @@ -345,8 +345,8 @@ A simple nd index iterator over an array. Example: - >>> a = array([[1,2],[3,4]]) - >>> for index, x in ndenumerate(a): + >>> a = np.array([[1,2],[3,4]]) + >>> for index, x in np.ndenumerate(a): ... print index, x (0, 0) 1 (0, 1) 2 @@ -369,7 +369,7 @@ will then return an N-dimensional counter. Example: - >>> for index in ndindex(3,2,1): + >>> for index in np.ndindex(3,2,1): ... print index (0, 0, 0) (0, 1, 0) Modified: trunk/numpy/lib/scimath.py =================================================================== --- trunk/numpy/lib/scimath.py 2008-07-09 20:25:41 UTC (rev 5381) +++ trunk/numpy/lib/scimath.py 2008-07-09 20:49:40 UTC (rev 5382) @@ -51,7 +51,7 @@ >>> a = np.array([1,2,3],np.short) >>> ac = np.lib.scimath._tocomplex(a); ac - array([ 1.+0.j, 2.+0.j, 3.+0.j], dtype=np.complex64) + array([ 1.+0.j, 2.+0.j, 3.+0.j], dtype=complex64) >>> ac.dtype dtype('complex64') From numpy-svn at scipy.org Wed Jul 9 22:48:13 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 9 Jul 2008 21:48:13 -0500 (CDT) Subject: [Numpy-svn] r5383 - branches/1.1.x/numpy/core/src Message-ID: <20080710024813.C5B4739C07A@scipy.org> Author: charris Date: 2008-07-09 21:48:10 -0500 (Wed, 09 Jul 2008) New Revision: 5383 Modified: branches/1.1.x/numpy/core/src/multiarraymodule.c branches/1.1.x/numpy/core/src/scalartypes.inc.src Log: Backport r5361 and r5362. Modified: branches/1.1.x/numpy/core/src/multiarraymodule.c =================================================================== --- branches/1.1.x/numpy/core/src/multiarraymodule.c 2008-07-09 20:49:40 UTC (rev 5382) +++ branches/1.1.x/numpy/core/src/multiarraymodule.c 2008-07-10 02:48:10 UTC (rev 5383) @@ -2139,12 +2139,18 @@ if (scalar == PyArray_NOSCALAR) { return PyArray_CanCastSafely(thistype, neededtype); } + from = PyArray_DescrFromType(thistype); if (from->f->cancastscalarkindto && (castlist = from->f->cancastscalarkindto[scalar])) { while (*castlist != PyArray_NOTYPE) - if (*castlist++ == neededtype) return 1; + if (*castlist++ == neededtype) { + Py_DECREF(from); + return 1; + } } + Py_DECREF(from); + switch(scalar) { case PyArray_BOOL_SCALAR: case PyArray_OBJECT_SCALAR: Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src =================================================================== --- branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-09 20:49:40 UTC (rev 5382) +++ branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-10 02:48:10 UTC (rev 5383) @@ -1830,7 +1830,10 @@ if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL; typecode = PyArray_DescrFromType(PyArray_ at TYPE@); - Py_INCREF(typecode); + /* + * typecode is new reference and stolen by + * PyArray_Scalar and others + */ if (obj == NULL) { #if @default@ == 0 char *mem; From numpy-svn at scipy.org Thu Jul 10 07:50:19 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 10 Jul 2008 06:50:19 -0500 (CDT) Subject: [Numpy-svn] r5384 - trunk/numpy/core/tests Message-ID: <20080710115019.2BCA739C424@scipy.org> Author: alan.mcintyre Date: 2008-07-10 06:50:15 -0500 (Thu, 10 Jul 2008) New Revision: 5384 Added: trunk/numpy/core/tests/test_defchararray.py Log: Added test module for chararray. Added: trunk/numpy/core/tests/test_defchararray.py =================================================================== --- trunk/numpy/core/tests/test_defchararray.py 2008-07-10 02:48:10 UTC (rev 5383) +++ trunk/numpy/core/tests/test_defchararray.py 2008-07-10 11:50:15 UTC (rev 5384) @@ -0,0 +1,89 @@ +from numpy.testing import * +from numpy.core import * +import numpy as np + +class TestBasic(TestCase): + def test_construction(self): + A = np.array([['abc', '123'], + ['789', 'xyz']]) + A1 = A.view(np.chararray) + A2 = np.chararray.__new__(np.chararray, A.shape, itemsize=A.itemsize, + buffer=A) + assert all(A1 == A2) + + +class TestWhitespace(TestCase): + def setUp(self): + self.A = np.array([['abc ', '123 '], + ['789 ', 'xyz ']]).view(np.chararray) + self.B = np.array([['abc', '123'], + ['789', 'xyz']]).view(np.chararray) + + def test1(self): + assert all(self.A == self.B) + + +class TestOperations(TestCase): + def setUp(self): + self.A = np.array([['abc', '123'], + ['789', 'xyz']]).view(np.chararray) + self.B = np.array([['efg', '456'], + ['051', 'tuv']]).view(np.chararray) + + def test_add(self): + AB = np.array([['abcefg', '123456'], + ['789051', 'xyztuv']]).view(np.chararray) + assert all(AB == (self.A + self.B)) + + def test_radd(self): + QA = np.array([['qabc', 'q123'], + ['q789', 'qxyz']]).view(np.chararray) + assert all(QA == ('q' + self.A)) + + def test_mul(self): + A2 = np.array([['abcabc', '123123'], + ['789789', 'xyzxyz']]).view(np.chararray) + + assert all(A2 == (self.A * 2)) + + for ob in [object(), 'qrs']: + try: + self.A * ob + except ValueError: + pass + else: + self.fail("chararray can only be multiplied by integers") + + def test_rmul(self): + A2 = np.array([['abcabc', '123123'], + ['789789', 'xyzxyz']]).view(np.chararray) + + assert all(A2 == (2 * self.A)) + + for ob in [object(), 'qrs']: + try: + ob * self.A + except ValueError: + pass + else: + self.fail("chararray can only be multiplied by integers") + + def test_mod(self): + pass + + def test_rmod(self): + assert ("%s" % self.A) == str(self.A) + assert ("%r" % self.A) == repr(self.A) + + for ob in [42, object()]: + try: + ob % self.A + except TypeError: + pass + else: + self.fail("chararray __rmod__ should fail with " \ + "non-string objects") + + +if __name__ == "__main__": + run_module_suite() From numpy-svn at scipy.org Thu Jul 10 08:47:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 10 Jul 2008 07:47:30 -0500 (CDT) Subject: [Numpy-svn] r5385 - trunk/numpy/core/tests Message-ID: <20080710124730.CB64239C4BF@scipy.org> Author: alan.mcintyre Date: 2008-07-10 07:47:28 -0500 (Thu, 10 Jul 2008) New Revision: 5385 Modified: trunk/numpy/core/tests/test_defchararray.py Log: Improve chararray __mul__/__rmul__ test so it should fail on 64-bit machines. Modified: trunk/numpy/core/tests/test_defchararray.py =================================================================== --- trunk/numpy/core/tests/test_defchararray.py 2008-07-10 11:50:15 UTC (rev 5384) +++ trunk/numpy/core/tests/test_defchararray.py 2008-07-10 12:47:28 UTC (rev 5385) @@ -41,10 +41,12 @@ assert all(QA == ('q' + self.A)) def test_mul(self): - A2 = np.array([['abcabc', '123123'], - ['789789', 'xyzxyz']]).view(np.chararray) + A = self.A + for r in (2,3,5,7,197): + Ar = np.array([[A[0,0]*r, A[0,1]*r], + [A[1,0]*r, A[1,1]*r]]).view(np.chararray) - assert all(A2 == (self.A * 2)) + assert all(Ar == (self.A * r)) for ob in [object(), 'qrs']: try: @@ -55,10 +57,12 @@ self.fail("chararray can only be multiplied by integers") def test_rmul(self): - A2 = np.array([['abcabc', '123123'], - ['789789', 'xyzxyz']]).view(np.chararray) + A = self.A + for r in (2,3,5,7,197): + Ar = np.array([[A[0,0]*r, A[0,1]*r], + [A[1,0]*r, A[1,1]*r]]).view(np.chararray) - assert all(A2 == (2 * self.A)) + assert all(Ar == (r * self.A)) for ob in [object(), 'qrs']: try: From numpy-svn at scipy.org Thu Jul 10 10:24:19 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 10 Jul 2008 09:24:19 -0500 (CDT) Subject: [Numpy-svn] r5386 - trunk/numpy/core/tests Message-ID: <20080710142419.ED8C539C02D@scipy.org> Author: alan.mcintyre Date: 2008-07-10 09:24:16 -0500 (Thu, 10 Jul 2008) New Revision: 5386 Modified: trunk/numpy/core/tests/test_defchararray.py Log: Comment out failing portions of __mul__ and __rmul__ until they are fixed in chararray. Modified: trunk/numpy/core/tests/test_defchararray.py =================================================================== --- trunk/numpy/core/tests/test_defchararray.py 2008-07-10 12:47:28 UTC (rev 5385) +++ trunk/numpy/core/tests/test_defchararray.py 2008-07-10 14:24:16 UTC (rev 5386) @@ -42,15 +42,15 @@ def test_mul(self): A = self.A - for r in (2,3,5,7,197): - Ar = np.array([[A[0,0]*r, A[0,1]*r], - [A[1,0]*r, A[1,1]*r]]).view(np.chararray) - - assert all(Ar == (self.A * r)) +# for r in (2,3,5,7,197): +# Ar = np.array([[A[0,0]*r, A[0,1]*r], +# [A[1,0]*r, A[1,1]*r]]).view(np.chararray) +# +# assert all(Ar == (self.A * r)) for ob in [object(), 'qrs']: try: - self.A * ob + A * ob except ValueError: pass else: @@ -58,15 +58,15 @@ def test_rmul(self): A = self.A - for r in (2,3,5,7,197): - Ar = np.array([[A[0,0]*r, A[0,1]*r], - [A[1,0]*r, A[1,1]*r]]).view(np.chararray) - - assert all(Ar == (r * self.A)) +# for r in (2,3,5,7,197): +# Ar = np.array([[A[0,0]*r, A[0,1]*r], +# [A[1,0]*r, A[1,1]*r]]).view(np.chararray) +# +# assert all(Ar == (r * self.A)) for ob in [object(), 'qrs']: try: - ob * self.A + ob * A except ValueError: pass else: From numpy-svn at scipy.org Thu Jul 10 13:44:22 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 10 Jul 2008 12:44:22 -0500 (CDT) Subject: [Numpy-svn] r5387 - trunk/numpy/doc/reference Message-ID: <20080710174422.1656739C559@scipy.org> Author: stefan Date: 2008-07-10 12:43:25 -0500 (Thu, 10 Jul 2008) New Revision: 5387 Added: trunk/numpy/doc/reference/basics.py trunk/numpy/doc/reference/creation.py trunk/numpy/doc/reference/howtofind.py trunk/numpy/doc/reference/internals.py trunk/numpy/doc/reference/io.py trunk/numpy/doc/reference/methods_vs_functions.py trunk/numpy/doc/reference/misc.py trunk/numpy/doc/reference/performance.py trunk/numpy/doc/reference/structured_arrays.py trunk/numpy/doc/reference/ufuncs.py trunk/numpy/doc/reference/zen.py Log: Add stubs for reference documentation. Added: trunk/numpy/doc/reference/basics.py =================================================================== --- trunk/numpy/doc/reference/basics.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/basics.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +============ +Array basics +============ + +Placeholder for array basics documentation. + +""" Added: trunk/numpy/doc/reference/creation.py =================================================================== --- trunk/numpy/doc/reference/creation.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/creation.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +============== +Array creation +============== + +Placeholder for array creation documentation. + +""" Added: trunk/numpy/doc/reference/howtofind.py =================================================================== --- trunk/numpy/doc/reference/howtofind.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/howtofind.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +================= +How to Find Stuff +================= + +How to find things in NumPy. + +""" Added: trunk/numpy/doc/reference/internals.py =================================================================== --- trunk/numpy/doc/reference/internals.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/internals.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +=============== +Array Internals +=============== + +Placeholder for Array Internals documentation. + +""" Added: trunk/numpy/doc/reference/io.py =================================================================== --- trunk/numpy/doc/reference/io.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/io.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +========= +Array I/O +========= + +Placeholder for array I/O documentation. + +""" Added: trunk/numpy/doc/reference/methods_vs_functions.py =================================================================== --- trunk/numpy/doc/reference/methods_vs_functions.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/methods_vs_functions.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +===================== +Methods vs. Functions +===================== + +Placeholder for Methods vs. Functions documentation. + +""" Added: trunk/numpy/doc/reference/misc.py =================================================================== --- trunk/numpy/doc/reference/misc.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/misc.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +============= +Miscellaneous +============= + +Placeholder for other tips. + +""" Added: trunk/numpy/doc/reference/performance.py =================================================================== --- trunk/numpy/doc/reference/performance.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/performance.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +=========== +Performance +=========== + +Placeholder for Improving Performance documentation. + +""" Added: trunk/numpy/doc/reference/structured_arrays.py =================================================================== --- trunk/numpy/doc/reference/structured_arrays.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/structured_arrays.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +================= +Structured Arrays +================= + +Placeholder for structured array documentation. + +""" Added: trunk/numpy/doc/reference/ufuncs.py =================================================================== --- trunk/numpy/doc/reference/ufuncs.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/ufuncs.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +=================== +Universal Functions +=================== + +Placeholder for ufunc documentation. + +""" Added: trunk/numpy/doc/reference/zen.py =================================================================== --- trunk/numpy/doc/reference/zen.py 2008-07-10 14:24:16 UTC (rev 5386) +++ trunk/numpy/doc/reference/zen.py 2008-07-10 17:43:25 UTC (rev 5387) @@ -0,0 +1,9 @@ +""" + +============ +Zen of NumPy +============ + +Placehold for Zen of NumPy documentation. + +""" From numpy-svn at scipy.org Thu Jul 10 14:26:46 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 10 Jul 2008 13:26:46 -0500 (CDT) Subject: [Numpy-svn] r5388 - trunk/numpy/doc/reference Message-ID: <20080710182646.978FC39C634@scipy.org> Author: stefan Date: 2008-07-10 13:26:29 -0500 (Thu, 10 Jul 2008) New Revision: 5388 Modified: trunk/numpy/doc/reference/__init__.py Log: Sort numpy.doc names. Modified: trunk/numpy/doc/reference/__init__.py =================================================================== --- trunk/numpy/doc/reference/__init__.py 2008-07-10 17:43:25 UTC (rev 5387) +++ trunk/numpy/doc/reference/__init__.py 2008-07-10 18:26:29 UTC (rev 5388) @@ -4,6 +4,7 @@ __all__ = [f[:-3] for f in os.listdir(ref_dir) if f.endswith('.py') and not f.startswith('__')] +__all__.sort() __doc__ = 'The following topics are available:\n' + \ '\n - '.join([''] + __all__) From numpy-svn at scipy.org Sat Jul 12 01:01:25 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 00:01:25 -0500 (CDT) Subject: [Numpy-svn] r5389 - trunk/numpy/core/src Message-ID: <20080712050125.84A9039C071@scipy.org> Author: charris Date: 2008-07-12 00:01:19 -0500 (Sat, 12 Jul 2008) New Revision: 5389 Modified: trunk/numpy/core/src/arrayobject.c Log: Coding style cleanups. Modified: trunk/numpy/core/src/arrayobject.c =================================================================== --- trunk/numpy/core/src/arrayobject.c 2008-07-10 18:26:29 UTC (rev 5388) +++ trunk/numpy/core/src/arrayobject.c 2008-07-12 05:01:19 UTC (rev 5389) @@ -9052,9 +9052,10 @@ if (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0; from = PyArray_DescrFromType(fromtype); - /* cancastto is a PyArray_NOTYPE terminated C-int-array of types that - the data-type can be cast to safely. - */ + /* + * cancastto is a PyArray_NOTYPE terminated C-int-array of types that + * the data-type can be cast to safely. + */ if (from->f->cancastto) { int *curtype; curtype = from->f->cancastto; @@ -11083,22 +11084,24 @@ static PyArray_Descr * PyArray_DescrNew(PyArray_Descr *base) { - PyArray_Descr *new; + PyArray_Descr *new = PyObject_New(PyArray_Descr, &PyArrayDescr_Type); - new = PyObject_New(PyArray_Descr, &PyArrayDescr_Type); - if (new == NULL) return NULL; + if (new == NULL) { + return NULL; + } /* Don't copy PyObject_HEAD part */ - memcpy((char *)new+sizeof(PyObject), - (char *)base+sizeof(PyObject), - sizeof(PyArray_Descr)-sizeof(PyObject)); + memcpy((char *)new + sizeof(PyObject), + (char *)base + sizeof(PyObject), + sizeof(PyArray_Descr) - sizeof(PyObject)); - if (new->fields == Py_None) new->fields = NULL; + if (new->fields == Py_None) { + new->fields = NULL; + } Py_XINCREF(new->fields); Py_XINCREF(new->names); if (new->subarray) { new->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr)); - memcpy(new->subarray, base->subarray, - sizeof(PyArray_ArrayDescr)); + memcpy(new->subarray, base->subarray, sizeof(PyArray_ArrayDescr)); Py_INCREF(new->subarray->shape); Py_INCREF(new->subarray->base); } From numpy-svn at scipy.org Sat Jul 12 01:04:45 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 00:04:45 -0500 (CDT) Subject: [Numpy-svn] r5390 - trunk/numpy/core/src Message-ID: <20080712050445.1413639C877@scipy.org> Author: charris Date: 2008-07-12 00:04:40 -0500 (Sat, 12 Jul 2008) New Revision: 5390 Modified: trunk/numpy/core/src/multiarraymodule.c Log: Coding style cleanups Modified: trunk/numpy/core/src/multiarraymodule.c =================================================================== --- trunk/numpy/core/src/multiarraymodule.c 2008-07-12 05:01:19 UTC (rev 5389) +++ trunk/numpy/core/src/multiarraymodule.c 2008-07-12 05:04:40 UTC (rev 5390) @@ -2091,12 +2091,12 @@ elsize = arr->descr->elsize; byteorder = arr->descr->byteorder; ptr = arr->data; - if (elsize > 1 && \ - (byteorder == PyArray_LITTLE || \ + if (elsize > 1 && + (byteorder == PyArray_LITTLE || (byteorder == PyArray_NATIVE && - PyArray_ISNBO(PyArray_LITTLE)))) - ptr += elsize-1; - + PyArray_ISNBO(PyArray_LITTLE)))) { + ptr += elsize - 1; + } return ((*ptr & bitmask) != 0); } @@ -2106,18 +2106,30 @@ PyArray_ScalarKind(int typenum, PyArrayObject **arr) { if (PyTypeNum_ISSIGNED(typenum)) { - if (arr && _signbit_set(*arr)) return PyArray_INTNEG_SCALAR; - else return PyArray_INTPOS_SCALAR; + if (arr && _signbit_set(*arr)) { + return PyArray_INTNEG_SCALAR; + } + else { + return PyArray_INTPOS_SCALAR; + } } - if (PyTypeNum_ISFLOAT(typenum)) return PyArray_FLOAT_SCALAR; - if (PyTypeNum_ISUNSIGNED(typenum)) return PyArray_INTPOS_SCALAR; - if (PyTypeNum_ISCOMPLEX(typenum)) return PyArray_COMPLEX_SCALAR; - if (PyTypeNum_ISBOOL(typenum)) return PyArray_BOOL_SCALAR; + if (PyTypeNum_ISFLOAT(typenum)) { + return PyArray_FLOAT_SCALAR; + } + if (PyTypeNum_ISUNSIGNED(typenum)) { + return PyArray_INTPOS_SCALAR; + } + if (PyTypeNum_ISCOMPLEX(typenum)) { + return PyArray_COMPLEX_SCALAR; + } + if (PyTypeNum_ISBOOL(typenum)) { + return PyArray_BOOL_SCALAR; + } if (PyTypeNum_ISUSERDEF(typenum)) { NPY_SCALARKIND retval; - PyArray_Descr* descr; - descr = PyArray_DescrFromType(typenum); + PyArray_Descr* descr = PyArray_DescrFromType(typenum); + if (descr->f->scalarkind) retval = descr->f->scalarkind((arr ? *arr : NULL)); else @@ -2156,7 +2168,9 @@ case PyArray_OBJECT_SCALAR: return PyArray_CanCastSafely(thistype, neededtype); default: - if (PyTypeNum_ISUSERDEF(neededtype)) return FALSE; + if (PyTypeNum_ISUSERDEF(neededtype)) { + return FALSE; + } switch(scalar) { case PyArray_INTPOS_SCALAR: return (neededtype >= PyArray_BYTE); From numpy-svn at scipy.org Sat Jul 12 01:11:35 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 00:11:35 -0500 (CDT) Subject: [Numpy-svn] r5391 - trunk/numpy/core/src Message-ID: <20080712051135.F0DC339C11D@scipy.org> Author: charris Date: 2008-07-12 00:11:32 -0500 (Sat, 12 Jul 2008) New Revision: 5391 Modified: trunk/numpy/core/src/ufuncobject.c Log: Coding style cleanups. Modified: trunk/numpy/core/src/ufuncobject.c =================================================================== --- trunk/numpy/core/src/ufuncobject.c 2008-07-12 05:04:40 UTC (rev 5390) +++ trunk/numpy/core/src/ufuncobject.c 2008-07-12 05:11:32 UTC (rev 5391) @@ -1039,9 +1039,10 @@ } -/* Called to determine coercion - Can change arg_types. -*/ +/* + * Called to determine coercion + * Can change arg_types. + */ static int select_types(PyUFuncObject *self, int *arg_types, @@ -1051,11 +1052,11 @@ { int i, j; char start_type; - int userdef=-1; - int userdef_ind=-1; + int userdef = -1; + int userdef_ind = -1; if (self->userloops) { - for(i=0; inin; i++) { + for(i = 0; i < self->nin; i++) { if (PyTypeNum_ISUSERDEF(arg_types[i])) { userdef = arg_types[i]; userdef_ind = i; @@ -1070,64 +1071,82 @@ if (userdef > 0) { PyObject *key, *obj; - int ret=-1; + int ret = -1; obj = NULL; - /* Look through all the registered loops for all the user-defined - types to find a match. + + /* + * Look through all the registered loops for all the user-defined + * types to find a match. */ while (ret == -1) { - if (userdef_ind >= self->nin) break; + if (userdef_ind >= self->nin) { + break; + } userdef = arg_types[userdef_ind++]; - if (!(PyTypeNum_ISUSERDEF(userdef))) continue; + if (!(PyTypeNum_ISUSERDEF(userdef))) { + continue; + } key = PyInt_FromLong((long) userdef); - if (key == NULL) return -1; + if (key == NULL) { + return -1; + } obj = PyDict_GetItem(self->userloops, key); Py_DECREF(key); - if (obj == NULL) continue; - /* extract the correct function - data and argtypes for this user-defined type. - */ + if (obj == NULL) { + continue; + } + /* + * extract the correct function + * data and argtypes for this user-defined type. + */ ret = _find_matching_userloop(obj, arg_types, scalars, function, data, self->nargs, self->nin); } - if (ret == 0) return ret; + if (ret == 0) { + return ret; + } PyErr_SetString(PyExc_TypeError, _types_msg); return ret; } start_type = arg_types[0]; - /* If the first argument is a scalar we need to place - the start type as the lowest type in the class - */ + /* + * If the first argument is a scalar we need to place + * the start type as the lowest type in the class + */ if (scalars[0] != PyArray_NOSCALAR) { start_type = _lowest_type(start_type); } i = 0; - while (intypes && start_type > self->types[i*self->nargs]) + while (i < self->ntypes && start_type > self->types[i*self->nargs]) { i++; - - for(;intypes; i++) { - for(j=0; jnin; j++) { + } + for (; i < self->ntypes; i++) { + for (j = 0; j < self->nin; j++) { if (!PyArray_CanCoerceScalar(arg_types[j], - self->types[i*self->nargs+j], + self->types[i*self->nargs + j], scalars[j])) break; } - if (j == self->nin) break; + if (j == self->nin) { + break; + } } - if(i>=self->ntypes) { + if (i >= self->ntypes) { PyErr_SetString(PyExc_TypeError, _types_msg); return -1; } - for(j=0; jnargs; j++) + for (j = 0; j < self->nargs; j++) { arg_types[j] = self->types[i*self->nargs+j]; - - if (self->data) + } + if (self->data) { *data = self->data[i]; - else + } + else { *data = NULL; + } *function = self->functions[i]; return 0; @@ -1153,9 +1172,11 @@ } *bufsize = PyInt_AsLong(PyList_GET_ITEM(ref, 0)); - if ((*bufsize == -1) && PyErr_Occurred()) return -1; - if ((*bufsize < PyArray_MIN_BUFSIZE) || \ - (*bufsize > PyArray_MAX_BUFSIZE) || \ + if ((*bufsize == -1) && PyErr_Occurred()) { + return -1; + } + if ((*bufsize < PyArray_MIN_BUFSIZE) || + (*bufsize > PyArray_MAX_BUFSIZE) || (*bufsize % 16 != 0)) { PyErr_Format(PyExc_ValueError, "buffer size (%d) is not in range " @@ -1167,8 +1188,10 @@ *errmask = PyInt_AsLong(PyList_GET_ITEM(ref, 1)); if (*errmask < 0) { - if (PyErr_Occurred()) return -1; - PyErr_Format(PyExc_ValueError, \ + if (PyErr_Occurred()) { + return -1; + } + PyErr_Format(PyExc_ValueError, "invalid error mask (%d)", *errmask); return -1; @@ -1191,7 +1214,9 @@ *errobj = Py_BuildValue("NO", PyString_FromString(name), retval); - if (*errobj == NULL) return -1; + if (*errobj == NULL) { + return -1; + } return 0; } @@ -1203,7 +1228,7 @@ PyUFunc_GetPyValues(char *name, int *bufsize, int *errmask, PyObject **errobj) { PyObject *thedict; - PyObject *ref=NULL; + PyObject *ref = NULL; #if USE_USE_DEFAULTS==1 if (PyUFunc_NUM_NODEFAULTS != 0) { From numpy-svn at scipy.org Sat Jul 12 01:14:43 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 00:14:43 -0500 (CDT) Subject: [Numpy-svn] r5392 - trunk/numpy/core/src Message-ID: <20080712051443.A658739C11D@scipy.org> Author: charris Date: 2008-07-12 00:14:39 -0500 (Sat, 12 Jul 2008) New Revision: 5392 Modified: trunk/numpy/core/src/arraytypes.inc.src Log: Coding style cleanups. Check return of PyArray_DescrNew for NULL (possible memory error). Modified: trunk/numpy/core/src/arraytypes.inc.src =================================================================== --- trunk/numpy/core/src/arraytypes.inc.src 2008-07-12 05:11:32 UTC (rev 5391) +++ trunk/numpy/core/src/arraytypes.inc.src 2008-07-12 05:14:39 UTC (rev 5392) @@ -2475,42 +2475,51 @@ static PyArray_Descr * PyArray_DescrFromType(int type) { - PyArray_Descr *ret=NULL; + PyArray_Descr *ret = NULL; if (type < PyArray_NTYPES) { ret = _builtin_descrs[type]; } else if (type == PyArray_NOTYPE) { - /* This needs to not raise an error so - that PyArray_DescrFromType(PyArray_NOTYPE) - works for backwards-compatible C-API + /* + * This needs to not raise an error so + * that PyArray_DescrFromType(PyArray_NOTYPE) + * works for backwards-compatible C-API */ return NULL; } - else if ((type == PyArray_CHAR) || \ - (type == PyArray_CHARLTR)) { + else if ((type == PyArray_CHAR) || (type == PyArray_CHARLTR)) { ret = PyArray_DescrNew(_builtin_descrs[PyArray_STRING]); + + if (ret == NULL) { + return NULL; + } ret->elsize = 1; ret->type = PyArray_CHARLTR; return ret; } - else if PyTypeNum_ISUSERDEF(type) { - ret = userdescrs[type-PyArray_USERDEF]; + else if (PyTypeNum_ISUSERDEF(type)) { + ret = userdescrs[type - PyArray_USERDEF]; } else { - int num=PyArray_NTYPES; - if (type < _MAX_LETTER) + int num = PyArray_NTYPES; + if (type < _MAX_LETTER) { num = (int) _letter_to_num[type]; - if (num >= PyArray_NTYPES) + } + if (num >= PyArray_NTYPES) { ret = NULL; - else + } + else { ret = _builtin_descrs[num]; + } } - if (ret==NULL) { + if (ret == NULL) { PyErr_SetString(PyExc_ValueError, "Invalid data-type for array"); } - else Py_INCREF(ret); + else { + Py_INCREF(ret); + } return ret; } From numpy-svn at scipy.org Sat Jul 12 01:17:46 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 00:17:46 -0500 (CDT) Subject: [Numpy-svn] r5393 - trunk/numpy/core/src Message-ID: <20080712051746.86A4A39C11D@scipy.org> Author: charris Date: 2008-07-12 00:17:43 -0500 (Sat, 12 Jul 2008) New Revision: 5393 Modified: trunk/numpy/core/src/scalartypes.inc.src Log: Small cleanups. Modified: trunk/numpy/core/src/scalartypes.inc.src =================================================================== --- trunk/numpy/core/src/scalartypes.inc.src 2008-07-12 05:14:39 UTC (rev 5392) +++ trunk/numpy/core/src/scalartypes.inc.src 2008-07-12 05:17:43 UTC (rev 5393) @@ -551,11 +551,10 @@ return ret; } /**begin repeat - -#name=float, double, longdouble# -#NAME=FLOAT, DOUBLE, LONGDOUBLE# -#PREFIX=NPY_,NPY_,NPY_# -*/ + * #name=float, double, longdouble# + * #NAME=FLOAT, DOUBLE, LONGDOUBLE# + * #PREFIX=NPY_,NPY_,NPY_# + */ static void format_ at name@(char *buf, size_t buflen, @name@ val, unsigned int precision) @@ -640,8 +639,9 @@ @name at type_@kind@(PyObject *self) { static char buf[100]; - format_ at name@(buf, sizeof(buf), - ((Py at Name@ScalarObject *)self)->obval, @NAME at PREC_@KIND@); + @name@ x = ((Py at Name@ScalarObject *)self)->obval; + + format_ at name@(buf, sizeof(buf), x, @NAME at PREC_@KIND@); return PyString_FromString(buf); } @@ -651,11 +651,10 @@ static char buf1[100]; static char buf2[100]; static char buf3[202]; - c at name@ x; - x = ((PyC at Name@ScalarObject *)self)->obval; + c at name@ x = ((PyC at Name@ScalarObject *)self)->obval; + format_ at name@(buf1, sizeof(buf1), x.real, @NAME at PREC_@KIND@); format_ at name@(buf2, sizeof(buf2), x.imag, @NAME at PREC_@KIND@); - snprintf(buf3, sizeof(buf3), "(%s+%sj)", buf1, buf2); return PyString_FromString(buf3); } @@ -2696,8 +2695,8 @@ PyCLongDoubleArrType_Type.tp_as_number = &clongdoubletype_as_number; /**begin repeat -#name=int, long, hex, oct, float, repr, str# -#kind=tp_as_number->nb*5, tp*2# + * #name=int, long, hex, oct, float, repr, str# + * #kind=tp_as_number->nb*5, tp*2# */ PyLongDoubleArrType_Type. at kind@_ at name@ = longdoubletype_ at name@; PyCLongDoubleArrType_Type. at kind@_ at name@ = clongdoubletype_ at name@; From numpy-svn at scipy.org Sat Jul 12 02:26:42 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 01:26:42 -0500 (CDT) Subject: [Numpy-svn] r5394 - trunk/numpy/core/src Message-ID: <20080712062642.E6FDD39C344@scipy.org> Author: charris Date: 2008-07-12 01:26:40 -0500 (Sat, 12 Jul 2008) New Revision: 5394 Modified: trunk/numpy/core/src/scalartypes.inc.src Log: Make buffers local for reentrancy. Modified: trunk/numpy/core/src/scalartypes.inc.src =================================================================== --- trunk/numpy/core/src/scalartypes.inc.src 2008-07-12 05:17:43 UTC (rev 5393) +++ trunk/numpy/core/src/scalartypes.inc.src 2008-07-12 06:26:40 UTC (rev 5394) @@ -553,7 +553,9 @@ /**begin repeat * #name=float, double, longdouble# * #NAME=FLOAT, DOUBLE, LONGDOUBLE# - * #PREFIX=NPY_,NPY_,NPY_# + * #PREFIX=NPY_, NPY_, NPY_# + * + * Fixme: buflen isn't checked when appending .0 */ static void format_ at name@(char *buf, size_t buflen, @name@ val, @@ -625,6 +627,8 @@ /* * float type str and repr + * + * These functions will return NULL if PyString creation fails. */ /**begin repeat * #name=float, double, longdouble# @@ -638,23 +642,23 @@ static PyObject * @name at type_@kind@(PyObject *self) { - static char buf[100]; - @name@ x = ((Py at Name@ScalarObject *)self)->obval; + char buf[100]; + @name@ val = ((Py at Name@ScalarObject *)self)->obval; - format_ at name@(buf, sizeof(buf), x, @NAME at PREC_@KIND@); + format_ at name@(buf, sizeof(buf), val, @NAME at PREC_@KIND@); return PyString_FromString(buf); } static PyObject * c at name@type_ at kind@(PyObject *self) { - static char buf1[100]; - static char buf2[100]; - static char buf3[202]; - c at name@ x = ((PyC at Name@ScalarObject *)self)->obval; + char buf1[100]; + char buf2[100]; + char buf3[202]; + c at name@ val = ((PyC at Name@ScalarObject *)self)->obval; - format_ at name@(buf1, sizeof(buf1), x.real, @NAME at PREC_@KIND@); - format_ at name@(buf2, sizeof(buf2), x.imag, @NAME at PREC_@KIND@); + format_ at name@(buf1, sizeof(buf1), val.real, @NAME at PREC_@KIND@); + format_ at name@(buf2, sizeof(buf2), val.imag, @NAME at PREC_@KIND@); snprintf(buf3, sizeof(buf3), "(%s+%sj)", buf1, buf2); return PyString_FromString(buf3); } From numpy-svn at scipy.org Sat Jul 12 17:45:11 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 16:45:11 -0500 (CDT) Subject: [Numpy-svn] r5395 - trunk/numpy/core/src Message-ID: <20080712214511.8790C39C226@scipy.org> Author: charris Date: 2008-07-12 16:45:08 -0500 (Sat, 12 Jul 2008) New Revision: 5395 Modified: trunk/numpy/core/src/scalartypes.inc.src Log: Make printing of complex numbers match Python. Modified: trunk/numpy/core/src/scalartypes.inc.src =================================================================== --- trunk/numpy/core/src/scalartypes.inc.src 2008-07-12 06:26:40 UTC (rev 5394) +++ trunk/numpy/core/src/scalartypes.inc.src 2008-07-12 21:45:08 UTC (rev 5395) @@ -553,30 +553,45 @@ /**begin repeat * #name=float, double, longdouble# * #NAME=FLOAT, DOUBLE, LONGDOUBLE# - * #PREFIX=NPY_, NPY_, NPY_# - * - * Fixme: buflen isn't checked when appending .0 */ + +#define FMT "%.*" NPY_ at NAME@_FMT +#define CFMT1 "%.*" NPY_ at NAME@_FMT "j" +#define CFMT2 "(%.*" NPY_ at NAME@_FMT "%+.*" NPY_ at NAME@_FMT "j)" + static void -format_ at name@(char *buf, size_t buflen, @name@ val, - unsigned int precision) +format_ at name@(char *buf, size_t buflen, @name@ val, unsigned int prec) { - char *cp; + int cnt, i; - PyOS_snprintf(buf, buflen, "%.*" @PREFIX@@NAME at _FMT, precision, val); - cp = buf; - if (*cp == '-') - cp++; - for (; *cp != '\0'; cp++) { - if (!isdigit(Py_CHARMASK(*cp))) + cnt = PyOS_snprintf(buf, buflen, FMT, prec, val); + + /* If nothing but digits after sign, append ".0" */ + for (i = (val < 0) ? 1 : 0; i < cnt; ++i) { + if (!isdigit(Py_CHARMASK(buf[i]))) { break; + } } - if (*cp == '\0') { - *cp++ = '.'; - *cp++ = '0'; - *cp++ = '\0'; + if (i == cnt && buflen >= cnt + 3) { + strcpy(&buf[cnt],".0"); } } + +static void +format_c at name@(char *buf, size_t buflen, c at name@ val, unsigned int prec) +{ + if (val.real == 0.0) { + PyOS_snprintf(buf, buflen, CFMT1, prec, val.imag); + } + else { + PyOS_snprintf(buf, buflen, CFMT2, prec, val.real, prec, val.imag); + } +} + +#undef FMT +#undef CFMT1 +#undef CFMT2 + /**end repeat**/ /* over-ride repr and str of array-scalar strings and unicode to @@ -639,29 +654,31 @@ * #kind = str, repr# * #KIND = STR, REPR# */ + +#define PREC @NAME at PREC_@KIND@ + static PyObject * @name at type_@kind@(PyObject *self) { char buf[100]; @name@ val = ((Py at Name@ScalarObject *)self)->obval; - format_ at name@(buf, sizeof(buf), val, @NAME at PREC_@KIND@); + format_ at name@(buf, sizeof(buf), val, PREC); return PyString_FromString(buf); } static PyObject * c at name@type_ at kind@(PyObject *self) { - char buf1[100]; - char buf2[100]; - char buf3[202]; + char buf[202]; c at name@ val = ((PyC at Name@ScalarObject *)self)->obval; - format_ at name@(buf1, sizeof(buf1), val.real, @NAME at PREC_@KIND@); - format_ at name@(buf2, sizeof(buf2), val.imag, @NAME at PREC_@KIND@); - snprintf(buf3, sizeof(buf3), "(%s+%sj)", buf1, buf2); - return PyString_FromString(buf3); + format_c at name@(buf, sizeof(buf), val, PREC); + return PyString_FromString(buf); } + +#undef PREC + /**end repeat1**/ /**end repeat**/ From numpy-svn at scipy.org Sat Jul 12 17:46:31 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 16:46:31 -0500 (CDT) Subject: [Numpy-svn] r5396 - trunk/numpy/core/tests Message-ID: <20080712214631.7D94439C226@scipy.org> Author: charris Date: 2008-07-12 16:46:29 -0500 (Sat, 12 Jul 2008) New Revision: 5396 Added: trunk/numpy/core/tests/test_print.py Log: Add basic tests of number str() formatting. Added: trunk/numpy/core/tests/test_print.py =================================================================== --- trunk/numpy/core/tests/test_print.py 2008-07-12 21:45:08 UTC (rev 5395) +++ trunk/numpy/core/tests/test_print.py 2008-07-12 21:46:29 UTC (rev 5396) @@ -0,0 +1,36 @@ +import numpy as np +from numpy.testing import * + +class TestPrint(TestCase): + + def test_float_types(self) : + """ Check formatting. + + This is only for the str function, and only for simple types. + The precision of np.float and np.longdouble aren't the same as the + python float precision. + + """ + for t in [np.float, np.double, np.longdouble] : + for x in [0, 1,-1, 1e10, 1e20] : + assert_equal(str(t(x)), str(float(x))) + + def test_complex_types(self) : + """Check formatting. + + This is only for the str function, and only for simple types. + The precision of np.float and np.longdouble aren't the same as the + python float precision. + + """ + for t in [np.cfloat, np.cdouble, np.clongdouble] : + for x in [0, 1,-1, 1e10, 1e20] : + assert_equal(str(t(x)), str(complex(x))) + assert_equal(str(t(x*1j)), str(complex(x*1j))) + assert_equal(str(t(x + x*1j)), str(complex(x + x*1j))) + + + + +if __name__ == "__main__": + run_module_suite() From numpy-svn at scipy.org Sat Jul 12 17:58:23 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 16:58:23 -0500 (CDT) Subject: [Numpy-svn] r5397 - branches/1.1.x/numpy/core/src Message-ID: <20080712215823.D155439C55E@scipy.org> Author: charris Date: 2008-07-12 16:58:19 -0500 (Sat, 12 Jul 2008) New Revision: 5397 Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src Log: Backport printing fixes for complex numbers. Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src =================================================================== --- branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-12 21:46:29 UTC (rev 5396) +++ branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-12 21:58:19 UTC (rev 5397) @@ -546,32 +546,49 @@ Py_DECREF(arr); return ret; } + /**begin repeat + * #name=float, double, longdouble# + * #NAME=FLOAT, DOUBLE, LONGDOUBLE# + */ -#name=float, double, longdouble# -#NAME=FLOAT, DOUBLE, LONGDOUBLE# -#PREFIX=NPY_,NPY_,NPY_# -*/ +#define FMT "%.*" NPY_ at NAME@_FMT +#define CFMT1 "%.*" NPY_ at NAME@_FMT "j" +#define CFMT2 "(%.*" NPY_ at NAME@_FMT "%+.*" NPY_ at NAME@_FMT "j)" + static void -format_ at name@(char *buf, size_t buflen, @name@ val, - unsigned int precision) +format_ at name@(char *buf, size_t buflen, @name@ val, unsigned int prec) { - char *cp; + int cnt, i; - PyOS_snprintf(buf, buflen, "%.*" @PREFIX@@NAME at _FMT, precision, val); - cp = buf; - if (*cp == '-') - cp++; - for (; *cp != '\0'; cp++) { - if (!isdigit(Py_CHARMASK(*cp))) - break; + cnt = PyOS_snprintf(buf, buflen, FMT, prec, val); + + /* If nothing but digits after sign, append ".0" */ + for (i = (val < 0) ? 1 : 0; i < cnt; ++i) { + if (!isdigit(Py_CHARMASK(buf[i]))) { + break; } - if (*cp == '\0') { - *cp++ = '.'; - *cp++ = '0'; - *cp++ = '\0'; - } + } + if (i == cnt && buflen >= cnt + 3) { + strcpy(&buf[cnt],".0"); + } } + +static void +format_c at name@(char *buf, size_t buflen, c at name@ val, unsigned int prec) +{ + if (val.real == 0.0) { + PyOS_snprintf(buf, buflen, CFMT1, prec, val.imag); + } + else { + PyOS_snprintf(buf, buflen, CFMT2, prec, val.real, prec, val.imag); + } +} + +#undef FMT +#undef CFMT1 +#undef CFMT2 + /**end repeat**/ /* over-ride repr and str of array-scalar strings and unicode to @@ -632,29 +649,31 @@ * #kind = str, repr# * #KIND = STR, REPR# */ + +#define PREC @NAME at PREC_@KIND@ + static PyObject * @name at type_@kind@(PyObject *self) { - static char buf[100]; - format_ at name@(buf, sizeof(buf), - ((Py at Name@ScalarObject *)self)->obval, @NAME at PREC_@KIND@); - return PyString_FromString(buf); + char buf[100]; + @name@ val = ((Py at Name@ScalarObject *)self)->obval; + + format_ at name@(buf, sizeof(buf), val, PREC); + return PyString_FromString(buf); } static PyObject * c at name@type_ at kind@(PyObject *self) { - static char buf1[100]; - static char buf2[100]; - static char buf3[202]; - c at name@ x; - x = ((PyC at Name@ScalarObject *)self)->obval; - format_ at name@(buf1, sizeof(buf1), x.real, @NAME at PREC_@KIND@); - format_ at name@(buf2, sizeof(buf2), x.imag, @NAME at PREC_@KIND@); + char buf[202]; + c at name@ val = ((PyC at Name@ScalarObject *)self)->obval; - snprintf(buf3, sizeof(buf3), "(%s+%sj)", buf1, buf2); - return PyString_FromString(buf3); + format_c at name@(buf, sizeof(buf), val, PREC); + return PyString_FromString(buf); } + +#undef PREC + /**end repeat1**/ /**end repeat**/ From numpy-svn at scipy.org Sat Jul 12 18:01:24 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 17:01:24 -0500 (CDT) Subject: [Numpy-svn] r5398 - in trunk/numpy/core: src tests Message-ID: <20080712220124.6847B39C55E@scipy.org> Author: charris Date: 2008-07-12 17:01:20 -0500 (Sat, 12 Jul 2008) New Revision: 5398 Modified: trunk/numpy/core/src/scalartypes.inc.src trunk/numpy/core/tests/test_print.py Log: Bit of whitespace removal. Modified: trunk/numpy/core/src/scalartypes.inc.src =================================================================== --- trunk/numpy/core/src/scalartypes.inc.src 2008-07-12 21:58:19 UTC (rev 5397) +++ trunk/numpy/core/src/scalartypes.inc.src 2008-07-12 22:01:20 UTC (rev 5398) @@ -550,6 +550,7 @@ Py_DECREF(arr); return ret; } + /**begin repeat * #name=float, double, longdouble# * #NAME=FLOAT, DOUBLE, LONGDOUBLE# Modified: trunk/numpy/core/tests/test_print.py =================================================================== --- trunk/numpy/core/tests/test_print.py 2008-07-12 21:58:19 UTC (rev 5397) +++ trunk/numpy/core/tests/test_print.py 2008-07-12 22:01:20 UTC (rev 5398) @@ -30,7 +30,5 @@ assert_equal(str(t(x + x*1j)), str(complex(x + x*1j))) - - if __name__ == "__main__": run_module_suite() From numpy-svn at scipy.org Sat Jul 12 19:49:13 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 12 Jul 2008 18:49:13 -0500 (CDT) Subject: [Numpy-svn] r5399 - trunk/numpy/core/src Message-ID: <20080712234913.D791839C7D7@scipy.org> Author: charris Date: 2008-07-12 18:49:10 -0500 (Sat, 12 Jul 2008) New Revision: 5399 Modified: trunk/numpy/core/src/arrayobject.c trunk/numpy/core/src/ufuncobject.c Log: Replace snprintf with PyOS_snprintf. There remain four occurrences of sprintf that should be replaced. Modified: trunk/numpy/core/src/arrayobject.c =================================================================== --- trunk/numpy/core/src/arrayobject.c 2008-07-12 22:01:20 UTC (rev 5398) +++ trunk/numpy/core/src/arrayobject.c 2008-07-12 23:49:10 UTC (rev 5399) @@ -4343,9 +4343,9 @@ if (repr) { if (PyArray_ISEXTENDED(self)) { char buf[100]; - snprintf(buf, sizeof(buf), "%d", self->descr->elsize); + PyOS_snprintf(buf, sizeof(buf), "%d", self->descr->elsize); sprintf(string+n, ", '%c%s')", self->descr->type, buf); - ret = PyString_FromStringAndSize(string, n+6+strlen(buf)); + ret = PyString_FromStringAndSize(string, n + 6 + strlen(buf)); } else { sprintf(string+n, ", '%c')", self->descr->type); @@ -4360,8 +4360,8 @@ return ret; } -static PyObject *PyArray_StrFunction=NULL; -static PyObject *PyArray_ReprFunction=NULL; +static PyObject *PyArray_StrFunction = NULL; +static PyObject *PyArray_ReprFunction = NULL; /*NUMPY_API Set the array print function to be a Python function. @@ -7358,8 +7358,8 @@ if (PyCObject_Check(ip)) { inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip); if (inter->two == 2) { - snprintf(buf, 40, "|%c%d", inter->typekind, - inter->itemsize); + PyOS_snprintf(buf, sizeof(buf), + "|%c%d", inter->typekind, inter->itemsize); chktype = _array_typedescr_fromstr(buf); } } @@ -8539,7 +8539,8 @@ } if (thetype == NULL) { - snprintf(buf, 40, "%c%c%d", endian, inter->typekind, inter->itemsize); + PyOS_snprintf(buf, sizeof(buf), + "%c%c%d", endian, inter->typekind, inter->itemsize); if (!(thetype=_array_typedescr_fromstr(buf))) { Py_DECREF(attr); return NULL; Modified: trunk/numpy/core/src/ufuncobject.c =================================================================== --- trunk/numpy/core/src/ufuncobject.c 2008-07-12 22:01:20 UTC (rev 5398) +++ trunk/numpy/core/src/ufuncobject.c 2008-07-12 23:49:10 UTC (rev 5399) @@ -670,7 +670,8 @@ switch(method) { case UFUNC_ERR_WARN: - snprintf(msg, 100, "%s encountered in %s", errtype, name); + PyOS_snprintf(msg, sizeof(msg), + "%s encountered in %s", errtype, name); if (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail; break; case UFUNC_ERR_RAISE: @@ -714,7 +715,8 @@ errtype, name); goto fail; } - snprintf(msg, 100, "Warning: %s encountered in %s\n", errtype, name); + PyOS_snprintf(msg, sizeof(msg), + "Warning: %s encountered in %s\n", errtype, name); ret = PyObject_CallMethod(pyfunc, "write", "s", msg); if (ret == NULL) goto fail; Py_DECREF(ret); From numpy-svn at scipy.org Sun Jul 13 14:19:21 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 13:19:21 -0500 (CDT) Subject: [Numpy-svn] r5400 - trunk/numpy/core/src Message-ID: <20080713181921.3641639C760@scipy.org> Author: charris Date: 2008-07-13 13:19:16 -0500 (Sun, 13 Jul 2008) New Revision: 5400 Modified: trunk/numpy/core/src/arrayobject.c Log: Deprecate PyArray_FromDims and PyArray_FromDimsAndDataAndDescr. There will be warnings issued in np.test() until fftpack is fixed. Modified: trunk/numpy/core/src/arrayobject.c =================================================================== --- trunk/numpy/core/src/arrayobject.c 2008-07-12 23:49:10 UTC (rev 5399) +++ trunk/numpy/core/src/arrayobject.c 2008-07-13 18:19:16 UTC (rev 5400) @@ -1311,26 +1311,24 @@ char *data) { PyObject *ret; -#if SIZEOF_INTP != SIZEOF_INT int i; intp newd[MAX_DIMS]; -#endif + char msg[] = "PyArray_FromDimsAndDataAndDescr"; + int err; + err = PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1); + if (err < 0) { + return NULL; + } if (!PyArray_ISNBO(descr->byteorder)) descr->byteorder = '='; - -#if SIZEOF_INTP != SIZEOF_INT - for(i=0; itype_num != PyArray_OBJECT)) { memset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret)); } From numpy-svn at scipy.org Sun Jul 13 15:22:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 14:22:30 -0500 (CDT) Subject: [Numpy-svn] r5401 - trunk/numpy/core/src Message-ID: <20080713192230.3653B39C8F4@scipy.org> Author: charris Date: 2008-07-13 14:22:26 -0500 (Sun, 13 Jul 2008) New Revision: 5401 Modified: trunk/numpy/core/src/arrayobject.c Log: Fix Deprecation warnings for python versions < 2.5.x Modified: trunk/numpy/core/src/arrayobject.c =================================================================== --- trunk/numpy/core/src/arrayobject.c 2008-07-13 18:19:16 UTC (rev 5400) +++ trunk/numpy/core/src/arrayobject.c 2008-07-13 19:22:26 UTC (rev 5401) @@ -22,6 +22,12 @@ */ /*#include */ +#if PY_VERSION_HEX >= 0x02050000 +#define DEPRECATE(msg) PyErr_WarnEx(PyExc_DeprecationWarning,msg,1) +#else +#define DEPRECATE(msg) PyErr_Warn(PyExc_DeprecationWarning,msg) +#endif + /*NUMPY_API * Get Priority from object */ @@ -1316,7 +1322,7 @@ char msg[] = "PyArray_FromDimsAndDataAndDescr"; int err; - err = PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1); + err = DEPRECATE(msg); if (err < 0) { return NULL; } @@ -1342,7 +1348,7 @@ char msg[] = "PyArray_FromDims"; int err; - err = PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1); + err = DEPRECATE(msg); if (err < 0) { return NULL; } From numpy-svn at scipy.org Sun Jul 13 17:43:01 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 16:43:01 -0500 (CDT) Subject: [Numpy-svn] r5402 - trunk/numpy/core/tests Message-ID: <20080713214301.4AE4539C4B4@scipy.org> Author: alan.mcintyre Date: 2008-07-13 16:42:52 -0500 (Sun, 13 Jul 2008) New Revision: 5402 Modified: trunk/numpy/core/tests/test_multiarray.py trunk/numpy/core/tests/test_numeric.py Log: Add tests to improve coverage. Modified: trunk/numpy/core/tests/test_multiarray.py =================================================================== --- trunk/numpy/core/tests/test_multiarray.py 2008-07-13 19:22:26 UTC (rev 5401) +++ trunk/numpy/core/tests/test_multiarray.py 2008-07-13 21:42:52 UTC (rev 5402) @@ -892,5 +892,26 @@ assert res.info == dat.info +class TestSummarization(TestCase): + def test_1d(self): + A = np.arange(1001) + strA = '[ 0 1 2 ..., 998 999 1000]' + assert str(A) == strA + + reprA = 'array([ 0, 1, 2, ..., 998, 999, 1000])' + assert repr(A) == reprA + + def test_2d(self): + A = np.arange(1002).reshape(2,501) + strA = '[[ 0 1 2 ..., 498 499 500]\n' \ + ' [ 501 502 503 ..., 999 1000 1001]]' + assert str(A) == strA + + reprA = 'array([[ 0, 1, 2, ..., 498, 499, 500],\n' \ + ' [ 501, 502, 503, ..., 999, 1000, 1001]])' + assert repr(A) == reprA + + + if __name__ == "__main__": run_module_suite() Modified: trunk/numpy/core/tests/test_numeric.py =================================================================== --- trunk/numpy/core/tests/test_numeric.py 2008-07-13 19:22:26 UTC (rev 5401) +++ trunk/numpy/core/tests/test_numeric.py 2008-07-13 21:42:52 UTC (rev 5402) @@ -817,6 +817,28 @@ assert_almost_equal(std(A)**2,real_var) +class TestLikeFuncs(TestCase): + '''Test zeros_like and empty_like''' + + def setUp(self): + self.data = [(array([[1,2,3],[4,5,6]],dtype=int32), (2,3), int32), + (array([[1,2,3],[4,5,6]],dtype=float32), (2,3), float32), + ] + + def test_zeros_like(self): + for d, dshape, dtype in self.data: + dz = zeros_like(d) + assert dz.shape == dshape + assert dz.dtype.type == dtype + assert all(abs(dz) == 0) + + def test_empty_like(self): + for d, dshape, dtype in self.data: + dz = zeros_like(d) + assert dz.shape == dshape + assert dz.dtype.type == dtype + + if __name__ == "__main__": run_module_suite() From numpy-svn at scipy.org Sun Jul 13 17:43:54 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 16:43:54 -0500 (CDT) Subject: [Numpy-svn] r5403 - trunk/numpy/lib Message-ID: <20080713214354.36B9939C8DA@scipy.org> Author: alan.mcintyre Date: 2008-07-13 16:43:50 -0500 (Sun, 13 Jul 2008) New Revision: 5403 Modified: trunk/numpy/lib/index_tricks.py Log: Fix doctests to run properly under new execution context. Modified: trunk/numpy/lib/index_tricks.py =================================================================== --- trunk/numpy/lib/index_tricks.py 2008-07-13 21:42:52 UTC (rev 5402) +++ trunk/numpy/lib/index_tricks.py 2008-07-13 21:43:50 UTC (rev 5403) @@ -102,7 +102,7 @@ Examples -------- - >>> mgrid = np.nd_grid() + >>> mgrid = np.lib.index_tricks.nd_grid() >>> mgrid[0:5,0:5] array([[[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], @@ -117,7 +117,7 @@ [0, 1, 2, 3, 4]]]) >>> mgrid[-1:1:5j] array([-1. , -0.5, 0. , 0.5, 1. ]) - >>> ogrid = nd_grid(sparse=True) + >>> ogrid = np.lib.index_tricks.nd_grid(sparse=True) >>> ogrid[0:5,0:5] [array([[0], [1], @@ -319,7 +319,7 @@ """Translates slice objects to concatenation along the first axis. For example: - >>> np.r_[array([1,2,3]), 0, 0, array([4,5,6])] + >>> np.r_[np.array([1,2,3]), 0, 0, np.array([4,5,6])] array([1, 2, 3, 0, 0, 4, 5, 6]) """ @@ -332,7 +332,7 @@ """Translates slice objects to concatenation along the second axis. For example: - >>> np.c_[array([[1,2,3]]), 0, 0, array([[4,5,6]])] + >>> np.c_[np.array([[1,2,3]]), 0, 0, np.array([[4,5,6]])] array([1, 2, 3, 0, 0, 4, 5, 6]) """ def __init__(self): From numpy-svn at scipy.org Sun Jul 13 17:47:49 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 16:47:49 -0500 (CDT) Subject: [Numpy-svn] r5404 - trunk/numpy/lib/tests Message-ID: <20080713214749.513E339C8DA@scipy.org> Author: alan.mcintyre Date: 2008-07-13 16:47:43 -0500 (Sun, 13 Jul 2008) New Revision: 5404 Modified: trunk/numpy/lib/tests/test_function_base.py trunk/numpy/lib/tests/test_index_tricks.py trunk/numpy/lib/tests/test_io.py trunk/numpy/lib/tests/test_shape_base.py trunk/numpy/lib/tests/test_type_check.py Log: Added tests to improve coverage. Renamed TestPiecewise methods so that they will be picked up by nose. Modified: trunk/numpy/lib/tests/test_function_base.py =================================================================== --- trunk/numpy/lib/tests/test_function_base.py 2008-07-13 21:43:50 UTC (rev 5403) +++ trunk/numpy/lib/tests/test_function_base.py 2008-07-13 21:47:43 UTC (rev 5404) @@ -616,8 +616,171 @@ assert(all(unique(x) == [1+1j, 1+10j, 5+6j, 10])) +class TestCheckFinite(TestCase): + def test_simple(self): + a = [1,2,3] + b = [1,2,inf] + c = [1,2,nan] + numpy.lib.asarray_chkfinite(a) + assert_raises(ValueError, numpy.lib.asarray_chkfinite, b) + assert_raises(ValueError, numpy.lib.asarray_chkfinite, c) + +class TestNaNFuncts(TestCase): + def setUp(self): + self.A = array([[[ nan, 0.01319214, 0.01620964], + [ 0.11704017, nan, 0.75157887], + [ 0.28333658, 0.1630199 , nan ]], + [[ 0.59541557, nan, 0.37910852], + [ nan, 0.87964135, nan ], + [ 0.70543747, nan, 0.34306596]], + [[ 0.72687499, 0.91084584, nan ], + [ 0.84386844, 0.38944762, 0.23913896], + [ nan, 0.37068164, 0.33850425]]]) + + def test_nansum(self): + assert_almost_equal(nansum(self.A), 8.0664079100000006) + assert_almost_equal(nansum(self.A,0), + array([[ 1.32229056, 0.92403798, 0.39531816], + [ 0.96090861, 1.26908897, 0.99071783], + [ 0.98877405, 0.53370154, 0.68157021]])) + assert_almost_equal(nansum(self.A,1), + array([[ 0.40037675, 0.17621204, 0.76778851], + [ 1.30085304, 0.87964135, 0.72217448], + [ 1.57074343, 1.6709751 , 0.57764321]])) + assert_almost_equal(nansum(self.A,2), + array([[ 0.02940178, 0.86861904, 0.44635648], + [ 0.97452409, 0.87964135, 1.04850343], + [ 1.63772083, 1.47245502, 0.70918589]])) + + def test_nanmin(self): + assert_almost_equal(nanmin(self.A), 0.01319214) + assert_almost_equal(nanmin(self.A,0), + array([[ 0.59541557, 0.01319214, 0.01620964], + [ 0.11704017, 0.38944762, 0.23913896], + [ 0.28333658, 0.1630199 , 0.33850425]])) + assert_almost_equal(nanmin(self.A,1), + array([[ 0.11704017, 0.01319214, 0.01620964], + [ 0.59541557, 0.87964135, 0.34306596], + [ 0.72687499, 0.37068164, 0.23913896]])) + assert_almost_equal(nanmin(self.A,2), + array([[ 0.01319214, 0.11704017, 0.1630199 ], + [ 0.37910852, 0.87964135, 0.34306596], + [ 0.72687499, 0.23913896, 0.33850425]])) + + def test_nanargmin(self): + assert_almost_equal(nanargmin(self.A), 1) + assert_almost_equal(nanargmin(self.A,0), + array([[1, 0, 0], + [0, 2, 2], + [0, 0, 2]])) + assert_almost_equal(nanargmin(self.A,1), + array([[1, 0, 0], + [0, 1, 2], + [0, 2, 1]])) + assert_almost_equal(nanargmin(self.A,2), + array([[1, 0, 1], + [2, 1, 2], + [0, 2, 2]])) + + def test_nanmax(self): + assert_almost_equal(nanmax(self.A), 0.91084584000000002) + assert_almost_equal(nanmax(self.A,0), + array([[ 0.72687499, 0.91084584, 0.37910852], + [ 0.84386844, 0.87964135, 0.75157887], + [ 0.70543747, 0.37068164, 0.34306596]])) + assert_almost_equal(nanmax(self.A,1), + array([[ 0.28333658, 0.1630199 , 0.75157887], + [ 0.70543747, 0.87964135, 0.37910852], + [ 0.84386844, 0.91084584, 0.33850425]])) + assert_almost_equal(nanmax(self.A,2), + array([[ 0.01620964, 0.75157887, 0.28333658], + [ 0.59541557, 0.87964135, 0.70543747], + [ 0.91084584, 0.84386844, 0.37068164]])) + + +class TestCorrCoef(TestCase): + def test_simple(self): + A = array([[ 0.15391142, 0.18045767, 0.14197213], + [ 0.70461506, 0.96474128, 0.27906989], + [ 0.9297531 , 0.32296769, 0.19267156]]) + B = array([[ 0.10377691, 0.5417086 , 0.49807457], + [ 0.82872117, 0.77801674, 0.39226705], + [ 0.9314666 , 0.66800209, 0.03538394]]) + assert_almost_equal(corrcoef(A), + array([[ 1. , 0.9379533 , -0.04931983], + [ 0.9379533 , 1. , 0.30007991], + [-0.04931983, 0.30007991, 1. ]])) + assert_almost_equal(corrcoef(A,B), + array([[ 1. , 0.9379533 , -0.04931983, + 0.30151751, 0.66318558, 0.51532523], + [ 0.9379533 , 1. , 0.30007991, + -0.04781421, 0.88157256, 0.78052386], + [-0.04931983, 0.30007991, 1. , + -0.96717111, 0.71483595, 0.83053601], + [ 0.30151751, -0.04781421, -0.96717111, + 1. , -0.51366032, -0.66173113], + [ 0.66318558, 0.88157256, 0.71483595, + -0.51366032, 1. , 0.98317823], + [ 0.51532523, 0.78052386, 0.83053601, + -0.66173113, 0.98317823, 1. ]])) + + + +class Test_i0(TestCase): + def test_simple(self): + assert_almost_equal(i0(0.5), array(1.0634833707413234)) + A = array([ 0.49842636, 0.6969809 , 0.22011976, 0.0155549]) + assert_almost_equal(i0(A), + array([ 1.06307822, 1.12518299, 1.01214991, 1.00006049])) + B = array([[ 0.827002 , 0.99959078], + [ 0.89694769, 0.39298162], + [ 0.37954418, 0.05206293], + [ 0.36465447, 0.72446427], + [ 0.48164949, 0.50324519]]) + assert_almost_equal(i0(B), + array([[ 1.17843223, 1.26583466], + [ 1.21147086, 1.0389829 ], + [ 1.03633899, 1.00067775], + [ 1.03352052, 1.13557954], + [ 1.0588429 , 1.06432317]])) + +class TestKaiser(TestCase): + def test_simple(self): + assert_almost_equal(kaiser(0,1.0), array([])) + assert isnan(kaiser(1,1.0)) + assert_almost_equal(kaiser(2,1.0), array([ 0.78984831, 0.78984831])) + assert_almost_equal(kaiser(5,1.0), + array([ 0.78984831, 0.94503323, 1. , + 0.94503323, 0.78984831])) + assert_almost_equal(kaiser(5,1.56789), + array([ 0.58285404, 0.88409679, 1. , + 0.88409679, 0.58285404])) + +class TestMsort(TestCase): + def test_simple(self): + A = array([[ 0.44567325, 0.79115165, 0.5490053 ], + [ 0.36844147, 0.37325583, 0.96098397], + [ 0.64864341, 0.52929049, 0.39172155]]) + assert_almost_equal(msort(A), + array([[ 0.36844147, 0.37325583, 0.39172155], + [ 0.44567325, 0.52929049, 0.5490053 ], + [ 0.64864341, 0.79115165, 0.96098397]])) + +class TestMeshgrid(TestCase): + def test_simple(self): + [X, Y] = meshgrid([1,2,3], [4,5,6,7]) + assert all(X == array([[1, 2, 3], + [1, 2, 3], + [1, 2, 3], + [1, 2, 3]])) + assert all(Y == array([[4, 4, 4], + [5, 5, 5], + [6, 6, 6], + [7, 7, 7]])) + + class TestPiecewise(TestCase): - def check_simple(self): + def test_simple(self): # Condition is single bool list x = piecewise([0, 0], [True, False], [1]) assert_array_equal(x, [1, 0]) @@ -645,7 +808,7 @@ x = piecewise([1, 2], [[True, False], [False, True]], [3, 4]) assert_array_equal(x, [3, 4]) - def check_default(self): + def test_default(self): # No value specified for x[1], should be 0 x = piecewise([1, 2], [True, False], [2]) assert_array_equal(x, [2, 0]) Modified: trunk/numpy/lib/tests/test_index_tricks.py =================================================================== --- trunk/numpy/lib/tests/test_index_tricks.py 2008-07-13 21:43:50 UTC (rev 5403) +++ trunk/numpy/lib/tests/test_index_tricks.py 2008-07-13 21:47:43 UTC (rev 5404) @@ -1,6 +1,13 @@ from numpy.testing import * -from numpy import array, ones, r_, mgrid +from numpy import array, ones, r_, mgrid, unravel_index +class TestUnravelIndex(TestCase): + def test_basic(self): + assert unravel_index(2,(2,2)) == (1,0) + assert unravel_index(254,(17,94)) == (2, 66) + assert_raises(ValueError, unravel_index, 4,(2,2)) + + class TestGrid(TestCase): def test_basic(self): a = mgrid[-1:1:10j] @@ -26,6 +33,7 @@ assert_array_almost_equal(d[0,1,:]-d[0,0,:], 0.1*ones(20,'d'),11) assert_array_almost_equal(d[1,:,1]-d[1,:,0], 0.2*ones(20,'d'),11) + class TestConcatenator(TestCase): def test_1d(self): assert_array_equal(r_[1,2,3,4,5,6],array([1,2,3,4,5,6])) Modified: trunk/numpy/lib/tests/test_io.py =================================================================== --- trunk/numpy/lib/tests/test_io.py 2008-07-13 21:43:50 UTC (rev 5403) +++ trunk/numpy/lib/tests/test_io.py 2008-07-13 21:47:43 UTC (rev 5404) @@ -2,6 +2,63 @@ import numpy as np import StringIO + +class RoundtripTest: + def test_array(self): + a = np.array( [[1,2],[3,4]], float) + self.do(a) + + a = np.array( [[1,2],[3,4]], int) + self.do(a) + + a = np.array( [[1+5j,2+6j],[3+7j,4+8j]], dtype=np.csingle) + self.do(a) + + a = np.array( [[1+5j,2+6j],[3+7j,4+8j]], dtype=np.cdouble) + self.do(a) + + def test_1D(self): + a = np.array([1,2,3,4], int) + self.do(a) + + def test_record(self): + a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')]) + self.do(a) + +class TestSaveLoad(RoundtripTest, TestCase): + def do(self, a): + c = StringIO.StringIO() + np.save(c, a) + c.seek(0) + a_reloaded = np.load(c) + assert_equal(a, a_reloaded) + + +class TestSavezLoad(RoundtripTest, TestCase): + def do(self, *arrays): + c = StringIO.StringIO() + np.savez(c, *arrays) + c.seek(0) + l = np.load(c) + for n, a in enumerate(arrays): + assert_equal(a, l['arr_%d' % n]) + + def test_multiple_arrays(self): + a = np.array( [[1,2],[3,4]], float) + b = np.array( [[1+2j,2+7j],[3-6j,4+12j]], complex) + self.do(a,b) + + def test_named_arrays(self): + a = np.array( [[1,2],[3,4]], float) + b = np.array( [[1+2j,2+7j],[3-6j,4+12j]], complex) + c = StringIO.StringIO() + np.savez(c, file_a=a, file_b=b) + c.seek(0) + l = np.load(c) + assert_equal(a, l['file_a']) + assert_equal(b, l['file_b']) + + class TestSaveTxt(TestCase): def test_array(self): a =np.array( [[1,2],[3,4]], float) @@ -32,6 +89,7 @@ np.savetxt(c, a, fmt='%d') c.seek(0) assert_equal(c.readlines(), ['1 2\n', '3 4\n']) + def test_delimiter(self): a = np.array([[1., 2.], [3., 4.]]) c = StringIO.StringIO() Modified: trunk/numpy/lib/tests/test_shape_base.py =================================================================== --- trunk/numpy/lib/tests/test_shape_base.py 2008-07-13 21:43:50 UTC (rev 5403) +++ trunk/numpy/lib/tests/test_shape_base.py 2008-07-13 21:47:43 UTC (rev 5404) @@ -17,6 +17,13 @@ [[27,30,33],[36,39,42],[45,48,51]]) +class TestApplyOverAxes(TestCase): + def test_simple(self): + a = arange(24).reshape(2,3,4) + aoa_a = apply_over_axes(sum, a, [0,2]) + assert_array_equal(aoa_a, array([[[60],[92],[124]]])) + + class TestArraySplit(TestCase): def test_integer_0_split(self): a = arange(10) Modified: trunk/numpy/lib/tests/test_type_check.py =================================================================== --- trunk/numpy/lib/tests/test_type_check.py 2008-07-13 21:43:50 UTC (rev 5403) +++ trunk/numpy/lib/tests/test_type_check.py 2008-07-13 21:47:43 UTC (rev 5404) @@ -1,11 +1,25 @@ from numpy.testing import * -import numpy.lib from numpy.lib import * from numpy.core import * def assert_all(x): assert(all(x)), x + +class TestCommonType(TestCase): + def test_basic(self): + ai32 = array([[1,2],[3,4]], dtype=int32) + af32 = array([[1,2],[3,4]], dtype=float32) + af64 = array([[1,2],[3,4]], dtype=float64) + acs = array([[1+5j,2+6j],[3+7j,4+8j]], dtype=csingle) + acd = array([[1+5j,2+6j],[3+7j,4+8j]], dtype=cdouble) + assert common_type(af32) == float32 + assert common_type(af64) == float64 + assert common_type(acs) == csingle + assert common_type(acd) == cdouble + + + class TestMintypecode(TestCase): def test_default_1(self): From numpy-svn at scipy.org Sun Jul 13 18:06:17 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 17:06:17 -0500 (CDT) Subject: [Numpy-svn] r5405 - trunk/numpy/testing Message-ID: <20080713220617.9B6E539C7B6@scipy.org> Author: alan.mcintyre Date: 2008-07-13 17:06:13 -0500 (Sun, 13 Jul 2008) New Revision: 5405 Modified: trunk/numpy/testing/nosetester.py trunk/numpy/testing/utils.py Log: Replaced utils.raises implementation with the nose function. Added utils.assert_raises (uses the function from nose). Wrapped text for test() deprecation warning. Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-13 21:47:43 UTC (rev 5404) +++ trunk/numpy/testing/nosetester.py 2008-07-13 22:06:13 UTC (rev 5405) @@ -294,7 +294,10 @@ # issue a deprecation warning if any of the pre-1.2 arguments to # test are given if old_args.intersection(kwargs.keys()): - warnings.warn("This method's signature will change in the next release; the level, verbosity, all, sys_argv, and testcase_pattern keyword arguments will be removed. Please update your code.", + warnings.warn("This method's signature will change in the next " \ + "release; the level, verbosity, all, sys_argv, " \ + "and testcase_pattern keyword arguments will be " \ + "removed. Please update your code.", DeprecationWarning, stacklevel=2) # Use old arguments if given (where it makes sense) Modified: trunk/numpy/testing/utils.py =================================================================== --- trunk/numpy/testing/utils.py 2008-07-13 21:47:43 UTC (rev 5404) +++ trunk/numpy/testing/utils.py 2008-07-13 22:06:13 UTC (rev 5405) @@ -7,11 +7,12 @@ import re import difflib import operator +from nosetester import import_nose __all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal', 'assert_array_equal', 'assert_array_less', 'assert_string_equal', - 'assert_array_almost_equal', 'build_err_msg', 'jiffies', 'memusage', - 'raises', 'rand', 'rundocs', 'runstring'] + 'assert_array_almost_equal', 'assert_raises', 'build_err_msg', + 'jiffies', 'memusage', 'raises', 'rand', 'rundocs', 'runstring'] def rand(*args): """Returns an array of random numbers with the given shape. @@ -319,32 +320,10 @@ return -def raises(*exceptions): - """ Assert that a test function raises one of the specified exceptions to - pass. - """ - # FIXME: when we transition to nose, just use its implementation. It's - # better. - def deco(function): - def f2(*args, **kwds): - try: - function(*args, **kwds) - except exceptions: - pass - except: - # Anything else. - raise - else: - raise AssertionError('%s() did not raise one of (%s)' % - (function.__name__, ', '.join([e.__name__ for e in exceptions]))) - try: - f2.__name__ = function.__name__ - except TypeError: - # Python 2.3 does not permit this. - pass - f2.__dict__ = function.__dict__ - f2.__doc__ = function.__doc__ - f2.__module__ = function.__module__ - return f2 +def raises(*args,**kwargs): + nose = import_nose() + return nose.tools.raises(*args,**kwargs) - return deco +def assert_raises(*args,**kwargs): + nose = import_nose() + return nose.tools.assert_raises(*args,**kwargs) From numpy-svn at scipy.org Sun Jul 13 18:15:18 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 17:15:18 -0500 (CDT) Subject: [Numpy-svn] r5406 - trunk/numpy/fft Message-ID: <20080713221518.96D6439C5A1@scipy.org> Author: charris Date: 2008-07-13 17:15:13 -0500 (Sun, 13 Jul 2008) New Revision: 5406 Modified: trunk/numpy/fft/fftpack_litemodule.c Log: Indentation and coding style cleanups. Modified: trunk/numpy/fft/fftpack_litemodule.c =================================================================== --- trunk/numpy/fft/fftpack_litemodule.c 2008-07-13 22:06:13 UTC (rev 5405) +++ trunk/numpy/fft/fftpack_litemodule.c 2008-07-13 22:15:13 UTC (rev 5406) @@ -6,82 +6,100 @@ /* ----------------------------------------------------- */ -static char fftpack_cfftf__doc__[] =""; +static char fftpack_cfftf__doc__[] = ""; PyObject * fftpack_cfftf(PyObject *self, PyObject *args) { - PyObject *op1, *op2; - PyArrayObject *data; - double *wsave, *dptr; - int npts, nsave, nrepeats, i; + PyObject *op1, *op2; + PyArrayObject *data; + double *wsave, *dptr; + int npts, nsave, nrepeats, i; - if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) return NULL; - data = (PyArrayObject *)PyArray_CopyFromObject(op1, PyArray_CDOUBLE, 1, 0); - if (data == NULL) return NULL; - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) - goto fail; - if (data == NULL) goto fail; + if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { + return NULL; + } + data = (PyArrayObject *)PyArray_CopyFromObject(op1, + PyArray_CDOUBLE, 1, 0); + if (data == NULL) { + return NULL; + } + if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) { + goto fail; + } + if (data == NULL) { + goto fail; + } - npts = data->dimensions[data->nd-1]; - if (nsave != npts*4+15) { - PyErr_SetString(ErrorObject, "invalid work array for fft size"); - goto fail; - } + npts = data->dimensions[data->nd - 1]; + if (nsave != npts*4 + 15) { + PyErr_SetString(ErrorObject, "invalid work array for fft size"); + goto fail; + } - nrepeats = PyArray_SIZE(data)/npts; - dptr = (double *)data->data; - NPY_SIGINT_ON - for (i=0; idata; + NPY_SIGINT_ON; + for (i = 0; i < nrepeats; i++) { + cfftf(npts, dptr, wsave); + dptr += npts*2; + } + NPY_SIGINT_OFF; + PyArray_Free(op2, (char *)wsave); + return (PyObject *)data; + fail: - PyArray_Free(op2, (char *)wsave); - Py_DECREF(data); - return NULL; + PyArray_Free(op2, (char *)wsave); + Py_DECREF(data); + return NULL; } -static char fftpack_cfftb__doc__[] =""; +static char fftpack_cfftb__doc__[] = ""; PyObject * fftpack_cfftb(PyObject *self, PyObject *args) { - PyObject *op1, *op2; - PyArrayObject *data; - double *wsave, *dptr; - int npts, nsave, nrepeats, i; + PyObject *op1, *op2; + PyArrayObject *data; + double *wsave, *dptr; + int npts, nsave, nrepeats, i; - if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) return NULL; - data = (PyArrayObject *)PyArray_CopyFromObject(op1, PyArray_CDOUBLE, 1, 0); - if (data == NULL) return NULL; - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) - goto fail; - if (data == NULL) goto fail; + if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { + return NULL; + } + data = (PyArrayObject *)PyArray_CopyFromObject(op1, + PyArray_CDOUBLE, 1, 0); + if (data == NULL) { + return NULL; + } + if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) { + goto fail; + } + if (data == NULL) { + goto fail; + } - npts = data->dimensions[data->nd-1]; - if (nsave != npts*4+15) { - PyErr_SetString(ErrorObject, "invalid work array for fft size"); - goto fail; - } + npts = data->dimensions[data->nd - 1]; + if (nsave != npts*4 + 15) { + PyErr_SetString(ErrorObject, "invalid work array for fft size"); + goto fail; + } - nrepeats = PyArray_SIZE(data)/npts; - dptr = (double *)data->data; - NPY_SIGINT_ON - for (i=0; idata; + NPY_SIGINT_ON; + for (i = 0; i < nrepeats; i++) { + cfftb(npts, dptr, wsave); + dptr += npts*2; + } + NPY_SIGINT_OFF; + PyArray_Free(op2, (char *)wsave); + return (PyObject *)data; + fail: - PyArray_Free(op2, (char *)wsave); - Py_DECREF(data); - return NULL; + PyArray_Free(op2, (char *)wsave); + Py_DECREF(data); + return NULL; } static char fftpack_cffti__doc__[] =""; @@ -89,21 +107,25 @@ static PyObject * fftpack_cffti(PyObject *self, PyObject *args) { - PyArrayObject *op; - int dim, n; + PyArrayObject *op; + int dim, n; - if (!PyArg_ParseTuple(args, "i", &n)) return NULL; + if (!PyArg_ParseTuple(args, "i", &n)) { + return NULL; + } + /*Magic size needed by cffti*/ + dim = 4*n + 15; + /*Create a 1 dimensional array of dimensions of type double*/ + op = (PyArrayObject *)PyArray_FromDims(1, &dim, PyArray_DOUBLE); + if (op == NULL) { + return NULL; + } - dim = 4*n+15; /*Magic size needed by cffti*/ - /*Create a 1 dimensional array of dimensions of type double*/ - op = (PyArrayObject *)PyArray_FromDims(1, &dim, PyArray_DOUBLE); - if (op == NULL) return NULL; + NPY_SIGINT_ON; + cffti(n, (double *)((PyArrayObject*)op)->data); + NPY_SIGINT_OFF; - NPY_SIGINT_ON - cffti(n, (double *)((PyArrayObject*)op)->data); - NPY_SIGINT_OFF - - return (PyObject *)op; + return (PyObject *)op; } static char fftpack_rfftf__doc__[] =""; @@ -111,53 +133,61 @@ PyObject * fftpack_rfftf(PyObject *self, PyObject *args) { - PyObject *op1, *op2; - PyArrayObject *data, *ret; - double *wsave, *dptr, *rptr; - int npts, nsave, nrepeats, i, rstep; + PyObject *op1, *op2; + PyArrayObject *data, *ret; + double *wsave, *dptr, *rptr; + int npts, nsave, nrepeats, i, rstep; - if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) return NULL; - data = (PyArrayObject *)PyArray_ContiguousFromObject(op1, PyArray_DOUBLE, 1, 0); - if (data == NULL) return NULL; - npts = data->dimensions[data->nd-1]; - data->dimensions[data->nd-1] = npts/2+1; - ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, - PyArray_DescrFromType(PyArray_CDOUBLE), 0); - data->dimensions[data->nd-1] = npts; - rstep = (ret->dimensions[ret->nd-1])*2; + if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { + return NULL; + } + data = (PyArrayObject *)PyArray_ContiguousFromObject(op1, + PyArray_DOUBLE, 1, 0); + if (data == NULL) { + return NULL; + } + npts = data->dimensions[data->nd-1]; + data->dimensions[data->nd - 1] = npts/2 + 1; + ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, + PyArray_DescrFromType(PyArray_CDOUBLE), 0); + data->dimensions[data->nd - 1] = npts; + rstep = (ret->dimensions[ret->nd - 1])*2; - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) - goto fail; - if (data == NULL || ret == NULL) goto fail; + if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) { + goto fail; + } + if (data == NULL || ret == NULL) { + goto fail; + } + if (nsave != npts*2+15) { + PyErr_SetString(ErrorObject, "invalid work array for fft size"); + goto fail; + } - if (nsave != npts*2+15) { - PyErr_SetString(ErrorObject, "invalid work array for fft size"); - goto fail; - } + nrepeats = PyArray_SIZE(data)/npts; + rptr = (double *)ret->data; + dptr = (double *)data->data; - nrepeats = PyArray_SIZE(data)/npts; - rptr = (double *)ret->data; - dptr = (double *)data->data; + NPY_SIGINT_ON; + for (i = 0; i < nrepeats; i++) { + memcpy((char *)(rptr+1), dptr, npts*sizeof(double)); + rfftf(npts, rptr+1, wsave); + rptr[0] = rptr[1]; + rptr[1] = 0.0; + rptr += rstep; + dptr += npts; + } + NPY_SIGINT_OFF; + PyArray_Free(op2, (char *)wsave); + Py_DECREF(data); + return (PyObject *)ret; - NPY_SIGINT_ON - for (i=0; idimensions[data->nd-1]; - ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, - PyArray_DescrFromType(PyArray_DOUBLE), 0); + if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { + return NULL; + } + data = (PyArrayObject *)PyArray_ContiguousFromObject(op1, + PyArray_CDOUBLE, 1, 0); + if (data == NULL) { + return NULL; + } + npts = data->dimensions[data->nd - 1]; + ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, + PyArray_DescrFromType(PyArray_DOUBLE), 0); - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) - goto fail; - if (data == NULL || ret == NULL) goto fail; + if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) { + goto fail; + } + if (data == NULL || ret == NULL) { + goto fail; + } + if (nsave != npts*2 + 15) { + PyErr_SetString(ErrorObject, "invalid work array for fft size"); + goto fail; + } - if (nsave != npts*2+15) { - PyErr_SetString(ErrorObject, "invalid work array for fft size"); - goto fail; - } + nrepeats = PyArray_SIZE(ret)/npts; + rptr = (double *)ret->data; + dptr = (double *)data->data; - nrepeats = PyArray_SIZE(ret)/npts; - rptr = (double *)ret->data; - dptr = (double *)data->data; + NPY_SIGINT_ON; + for (i=0; idata); - NPY_SIGINT_OFF + NPY_SIGINT_OFF; return (PyObject *)op; } @@ -237,13 +278,13 @@ /* List of methods defined in the module */ static struct PyMethodDef fftpack_methods[] = { - {"cfftf", fftpack_cfftf, 1, fftpack_cfftf__doc__}, - {"cfftb", fftpack_cfftb, 1, fftpack_cfftb__doc__}, - {"cffti", fftpack_cffti, 1, fftpack_cffti__doc__}, - {"rfftf", fftpack_rfftf, 1, fftpack_rfftf__doc__}, - {"rfftb", fftpack_rfftb, 1, fftpack_rfftb__doc__}, - {"rffti", fftpack_rffti, 1, fftpack_rffti__doc__}, - {NULL, NULL} /* sentinel */ + {"cfftf", fftpack_cfftf, 1, fftpack_cfftf__doc__}, + {"cfftb", fftpack_cfftb, 1, fftpack_cfftb__doc__}, + {"cffti", fftpack_cffti, 1, fftpack_cffti__doc__}, + {"rfftf", fftpack_rfftf, 1, fftpack_rfftf__doc__}, + {"rfftb", fftpack_rfftb, 1, fftpack_rfftb__doc__}, + {"rffti", fftpack_rffti, 1, fftpack_rffti__doc__}, + {NULL, NULL} /* sentinel */ }; @@ -255,21 +296,21 @@ PyMODINIT_FUNC initfftpack_lite(void) { - PyObject *m, *d; + PyObject *m, *d; - /* Create the module and add the functions */ - m = Py_InitModule4("fftpack_lite", fftpack_methods, - fftpack_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); + /* Create the module and add the functions */ + m = Py_InitModule4("fftpack_lite", fftpack_methods, + fftpack_module_documentation, + (PyObject*)NULL,PYTHON_API_VERSION); - /* Import the array object */ - import_array(); + /* Import the array object */ + import_array(); - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - ErrorObject = PyErr_NewException("fftpack.error", NULL, NULL); - PyDict_SetItemString(d, "error", ErrorObject); + /* Add some symbolic constants to the module */ + d = PyModule_GetDict(m); + ErrorObject = PyErr_NewException("fftpack.error", NULL, NULL); + PyDict_SetItemString(d, "error", ErrorObject); - /* XXXX Add constants here */ + /* XXXX Add constants here */ } From numpy-svn at scipy.org Sun Jul 13 19:56:59 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 18:56:59 -0500 (CDT) Subject: [Numpy-svn] r5407 - in trunk/numpy: core/include/numpy core/src fft Message-ID: <20080713235659.4179E39C2C6@scipy.org> Author: charris Date: 2008-07-13 18:56:51 -0500 (Sun, 13 Jul 2008) New Revision: 5407 Modified: trunk/numpy/core/include/numpy/ndarrayobject.h trunk/numpy/core/src/arrayobject.c trunk/numpy/core/src/multiarraymodule.c trunk/numpy/fft/fftpack_litemodule.c Log: Move DEPRECATE macro to ndarrayobject.h. Deprecate PyArray_As1D. Remove deprecated functions from fftpack_listmodule.c. There may need to be further fixes on 64 bit platforms, we will see. Modified: trunk/numpy/core/include/numpy/ndarrayobject.h =================================================================== --- trunk/numpy/core/include/numpy/ndarrayobject.h 2008-07-13 22:15:13 UTC (rev 5406) +++ trunk/numpy/core/include/numpy/ndarrayobject.h 2008-07-13 23:56:51 UTC (rev 5407) @@ -1,4 +1,5 @@ -/* DON'T INCLUDE THIS DIRECTLY. +/* + * DON'T INCLUDE THIS DIRECTLY. */ #ifndef NPY_NDARRAYOBJECT_H @@ -2007,4 +2008,12 @@ } #endif +/* Define python version independent deprecation macro */ + +#if PY_VERSION_HEX >= 0x02050000 +#define DEPRECATE(msg) PyErr_WarnEx(PyExc_DeprecationWarning,msg,1) +#else +#define DEPRECATE(msg) PyErr_Warn(PyExc_DeprecationWarning,msg) +#endif + #endif /* NPY_NDARRAYOBJECT_H */ Modified: trunk/numpy/core/src/arrayobject.c =================================================================== --- trunk/numpy/core/src/arrayobject.c 2008-07-13 22:15:13 UTC (rev 5406) +++ trunk/numpy/core/src/arrayobject.c 2008-07-13 23:56:51 UTC (rev 5407) @@ -22,12 +22,6 @@ */ /*#include */ -#if PY_VERSION_HEX >= 0x02050000 -#define DEPRECATE(msg) PyErr_WarnEx(PyExc_DeprecationWarning,msg,1) -#else -#define DEPRECATE(msg) PyErr_Warn(PyExc_DeprecationWarning,msg) -#endif - /*NUMPY_API * Get Priority from object */ Modified: trunk/numpy/core/src/multiarraymodule.c =================================================================== --- trunk/numpy/core/src/multiarraymodule.c 2008-07-13 22:15:13 UTC (rev 5406) +++ trunk/numpy/core/src/multiarraymodule.c 2008-07-13 23:56:51 UTC (rev 5407) @@ -1665,7 +1665,13 @@ { intp newd1; PyArray_Descr *descr; + int err; + char msg[] = "PyArray_As1D: use PyArray_AsCArray instead."; + err = DEPRECATE(msg); + if (err < 0) { + return -1; + } descr = PyArray_DescrFromType(typecode); if (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, descr) == -1) return -1; Modified: trunk/numpy/fft/fftpack_litemodule.c =================================================================== --- trunk/numpy/fft/fftpack_litemodule.c 2008-07-13 22:15:13 UTC (rev 5406) +++ trunk/numpy/fft/fftpack_litemodule.c 2008-07-13 23:56:51 UTC (rev 5407) @@ -13,8 +13,10 @@ { PyObject *op1, *op2; PyArrayObject *data; + PyArray_Descr *descr; double *wsave, *dptr; - int npts, nsave, nrepeats, i; + npy_intp nsave; + int npts, nrepeats, i; if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { return NULL; @@ -24,7 +26,8 @@ if (data == NULL) { return NULL; } - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) { + descr = PyArray_DescrFromType(PyArray_DOUBLE); + if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) { goto fail; } if (data == NULL) { @@ -61,8 +64,10 @@ { PyObject *op1, *op2; PyArrayObject *data; + PyArray_Descr *descr; double *wsave, *dptr; - int npts, nsave, nrepeats, i; + npy_intp nsave; + int npts, nrepeats, i; if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { return NULL; @@ -72,7 +77,8 @@ if (data == NULL) { return NULL; } - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) { + descr = PyArray_DescrFromType(PyArray_DOUBLE); + if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) { goto fail; } if (data == NULL) { @@ -108,15 +114,16 @@ fftpack_cffti(PyObject *self, PyObject *args) { PyArrayObject *op; - int dim, n; + npy_intp dim; + long n; - if (!PyArg_ParseTuple(args, "i", &n)) { + if (!PyArg_ParseTuple(args, "l", &n)) { return NULL; } /*Magic size needed by cffti*/ dim = 4*n + 15; /*Create a 1 dimensional array of dimensions of type double*/ - op = (PyArrayObject *)PyArray_FromDims(1, &dim, PyArray_DOUBLE); + op = (PyArrayObject *)PyArray_SimpleNew(1, &dim, PyArray_DOUBLE); if (op == NULL) { return NULL; } @@ -135,8 +142,10 @@ { PyObject *op1, *op2; PyArrayObject *data, *ret; + PyArray_Descr *descr; double *wsave, *dptr, *rptr; - int npts, nsave, nrepeats, i, rstep; + npy_intp nsave; + int npts, nrepeats, i, rstep; if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { return NULL; @@ -153,7 +162,8 @@ data->dimensions[data->nd - 1] = npts; rstep = (ret->dimensions[ret->nd - 1])*2; - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) { + descr = PyArray_DescrFromType(PyArray_DOUBLE); + if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) { goto fail; } if (data == NULL || ret == NULL) { @@ -198,8 +208,10 @@ { PyObject *op1, *op2; PyArrayObject *data, *ret; + PyArray_Descr *descr; double *wsave, *dptr, *rptr; - int npts, nsave, nrepeats, i; + npy_intp nsave; + int npts, nrepeats, i; if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { return NULL; @@ -213,7 +225,8 @@ ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, PyArray_DescrFromType(PyArray_DOUBLE), 0); - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) { + descr = PyArray_DescrFromType(PyArray_DOUBLE); + if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) { goto fail; } if (data == NULL || ret == NULL) { @@ -229,8 +242,8 @@ dptr = (double *)data->data; NPY_SIGINT_ON; - for (i=0; i Author: alan.mcintyre Date: 2008-07-13 19:27:38 -0500 (Sun, 13 Jul 2008) New Revision: 5408 Modified: trunk/numpy/linalg/tests/test_linalg.py Log: Added tests for eigenvalue/vector functions for Hermitian matrices.. Modified: trunk/numpy/linalg/tests/test_linalg.py =================================================================== --- trunk/numpy/linalg/tests/test_linalg.py 2008-07-13 23:56:51 UTC (rev 5407) +++ trunk/numpy/linalg/tests/test_linalg.py 2008-07-14 00:27:38 UTC (rev 5408) @@ -202,5 +202,60 @@ assert_equal(matrix_power(A,2),A) +class HermitianTestCase: + def test_single(self): + a = array([[1.,2.], [2.,1.]], dtype=single) + self.do(a) + + def test_double(self): + a = array([[1.,2.], [2.,1.]], dtype=double) + self.do(a) + + def test_csingle(self): + a = array([[1.,2+3j], [2-3j,1]], dtype=csingle) + self.do(a) + + def test_cdouble(self): + a = array([[1.,2+3j], [2-3j,1]], dtype=cdouble) + self.do(a) + + def test_empty(self): + a = atleast_2d(array([], dtype = double)) + assert_raises(linalg.LinAlgError, self.do, a) + + def test_nonarray(self): + a = [[1,2], [2,1]] + self.do(a) + + def test_matrix_b_only(self): + """Check that matrix type is preserved.""" + a = array([[1.,2.], [2.,1.]]) + self.do(a) + + def test_matrix_a_and_b(self): + """Check that matrix type is preserved.""" + a = matrix([[1.,2.], [2.,1.]]) + self.do(a) + +class TestEigvalsh(HermitianTestCase, TestCase): + def do(self, a): + ev = linalg.eigvalsh(a) + # flip resulting eigenvalue array, since they are returned in + # reverse order from the values given by linal.eig + ev = ev[::-1] + + evalues, evectors = linalg.eig(a) + assert_almost_equal(ev, evalues) + +class TestEigh(HermitianTestCase, TestCase): + def do(self, a): + ev, evc = linalg.eigh(a) + # flip resulting eigenvalue array, since they are returned in + # reverse order from the values given by linal.eig + ev = ev[::-1] + + evalues, evectors = linalg.eig(a) + assert_almost_equal(ev, evalues) + if __name__ == "__main__": run_module_suite() From numpy-svn at scipy.org Sun Jul 13 20:29:19 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 13 Jul 2008 19:29:19 -0500 (CDT) Subject: [Numpy-svn] r5409 - trunk/numpy/lib/tests Message-ID: <20080714002919.C396339C19A@scipy.org> Author: alan.mcintyre Date: 2008-07-13 19:29:17 -0500 (Sun, 13 Jul 2008) New Revision: 5409 Modified: trunk/numpy/lib/tests/test_stride_tricks.py Log: Make use of assert_raises from numpy.testing, and added run_module_suite to support running test module stand-alone. Modified: trunk/numpy/lib/tests/test_stride_tricks.py =================================================================== --- trunk/numpy/lib/tests/test_stride_tricks.py 2008-07-14 00:27:38 UTC (rev 5408) +++ trunk/numpy/lib/tests/test_stride_tricks.py 2008-07-14 00:29:17 UTC (rev 5409) @@ -1,7 +1,5 @@ -from nose.tools import assert_raises import numpy as np -from numpy.testing import assert_array_equal - +from numpy.testing import * from numpy.lib.stride_tricks import broadcast_arrays @@ -204,3 +202,7 @@ if () not in input_shapes: yield assert_same_as_ufunc, input_shapes[0], input_shapes[1], False, True yield assert_same_as_ufunc, input_shapes[0], input_shapes[1], True, True + + +if __name__ == "__main__": + run_module_suite() From numpy-svn at scipy.org Mon Jul 14 01:37:43 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 14 Jul 2008 00:37:43 -0500 (CDT) Subject: [Numpy-svn] r5410 - trunk/numpy/core/src Message-ID: <20080714053743.3095239C677@scipy.org> Author: charris Date: 2008-07-14 00:37:40 -0500 (Mon, 14 Jul 2008) New Revision: 5410 Modified: trunk/numpy/core/src/arrayobject.c trunk/numpy/core/src/multiarraymodule.c Log: Make deprecation messages more informative. Modified: trunk/numpy/core/src/arrayobject.c =================================================================== --- trunk/numpy/core/src/arrayobject.c 2008-07-14 00:29:17 UTC (rev 5409) +++ trunk/numpy/core/src/arrayobject.c 2008-07-14 05:37:40 UTC (rev 5410) @@ -1313,11 +1313,9 @@ PyObject *ret; int i; intp newd[MAX_DIMS]; - char msg[] = "PyArray_FromDimsAndDataAndDescr"; - int err; + char msg[] = "PyArray_FromDimsAndDataAndDescr: use PyArray_NewFromDescr."; - err = DEPRECATE(msg); - if (err < 0) { + if (DEPRECATE(msg) < 0) { return NULL; } if (!PyArray_ISNBO(descr->byteorder)) @@ -1339,11 +1337,9 @@ PyArray_FromDims(int nd, int *d, int type) { PyObject *ret; - char msg[] = "PyArray_FromDims"; - int err; + char msg[] = "PyArray_FromDims: use PyArray_SimpleNew."; - err = DEPRECATE(msg); - if (err < 0) { + if (DEPRECATE(msg) < 0) { return NULL; } ret = PyArray_FromDimsAndDataAndDescr(nd, d, Modified: trunk/numpy/core/src/multiarraymodule.c =================================================================== --- trunk/numpy/core/src/multiarraymodule.c 2008-07-14 00:29:17 UTC (rev 5409) +++ trunk/numpy/core/src/multiarraymodule.c 2008-07-14 05:37:40 UTC (rev 5410) @@ -1665,11 +1665,9 @@ { intp newd1; PyArray_Descr *descr; - int err; - char msg[] = "PyArray_As1D: use PyArray_AsCArray instead."; + char msg[] = "PyArray_As1D: use PyArray_AsCArray."; - err = DEPRECATE(msg); - if (err < 0) { + if (DEPRECATE(msg) < 0) { return -1; } descr = PyArray_DescrFromType(typecode); From numpy-svn at scipy.org Mon Jul 14 22:20:52 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 14 Jul 2008 21:20:52 -0500 (CDT) Subject: [Numpy-svn] r5411 - trunk/numpy/testing Message-ID: <20080715022052.3D09139C036@scipy.org> Author: alan.mcintyre Date: 2008-07-14 21:20:49 -0500 (Mon, 14 Jul 2008) New Revision: 5411 Modified: trunk/numpy/testing/nosetester.py Log: Reset doctest.master on each test run to avoid messages about "'__main__' in both testers" when test() is run multiple times. Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-14 05:37:40 UTC (rev 5410) +++ trunk/numpy/testing/nosetester.py 2008-07-15 02:20:49 UTC (rev 5411) @@ -350,6 +350,10 @@ self.result = self.testRunner.run(self.test) self.success = self.result.wasSuccessful() return self.success + + # reset doctest state + import doctest + doctest.master = None t = NumpyTestProgram(argv=argv, exit=False) return t.result From numpy-svn at scipy.org Tue Jul 15 03:06:58 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 02:06:58 -0500 (CDT) Subject: [Numpy-svn] r5412 - trunk/numpy/doc/reference Message-ID: <20080715070658.A96EB39C773@scipy.org> Author: stefan Date: 2008-07-15 02:06:38 -0500 (Tue, 15 Jul 2008) New Revision: 5412 Added: trunk/numpy/doc/reference/glossary.py Log: Add place-holder for doc.glossary. Added: trunk/numpy/doc/reference/glossary.py =================================================================== --- trunk/numpy/doc/reference/glossary.py 2008-07-15 02:20:49 UTC (rev 5411) +++ trunk/numpy/doc/reference/glossary.py 2008-07-15 07:06:38 UTC (rev 5412) @@ -0,0 +1,9 @@ +""" + +================= +Glossary +================= + +Place-holder for a glossary. + +""" From numpy-svn at scipy.org Tue Jul 15 03:38:15 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 02:38:15 -0500 (CDT) Subject: [Numpy-svn] r5413 - branches/1.1.x/numpy/doc Message-ID: <20080715073815.B6F2939C7DE@scipy.org> Author: stefan Date: 2008-07-15 02:38:00 -0500 (Tue, 15 Jul 2008) New Revision: 5413 Added: branches/1.1.x/numpy/doc/EXAMPLE_DOCSTRING.txt Modified: branches/1.1.x/numpy/doc/HOWTO_DOCUMENT.txt branches/1.1.x/numpy/doc/example.py Log: Back-port changes to documentation standard. Added: branches/1.1.x/numpy/doc/EXAMPLE_DOCSTRING.txt =================================================================== --- branches/1.1.x/numpy/doc/EXAMPLE_DOCSTRING.txt 2008-07-15 07:06:38 UTC (rev 5412) +++ branches/1.1.x/numpy/doc/EXAMPLE_DOCSTRING.txt 2008-07-15 07:38:00 UTC (rev 5413) @@ -0,0 +1,104 @@ +.. Here follows an example docstring for a C-function. Note that the + signature is given. This is done only for functions written is C, + since Python cannot find their signature by inspection. For all + other functions, start with the one line description. + + +multivariate_normal(mean, cov[, shape]) + +Draw samples from a multivariate normal distribution. + +The multivariate normal, multinormal or Gaussian distribution is a +generalisation of the one-dimensional normal distribution to higher +dimensions. + +Such a distribution is specified by its mean and covariance matrix, +which are analogous to the mean (average or "centre") and variance +(standard deviation squared or "width") of the one-dimensional normal +distribution. + +Parameters +---------- +mean : (N,) ndarray + Mean of the N-dimensional distribution. +cov : (N,N) ndarray + Covariance matrix of the distribution. +shape : tuple of ints, optional + Given a shape of, for example, (m,n,k), m*n*k samples are + generated, and packed in an m-by-n-by-k arrangement. Because each + sample is N-dimensional, the output shape is (m,n,k,N). If no + shape is specified, a single sample is returned. + +Returns +------- +out : ndarray + The drawn samples, arranged according to `shape`. If the + shape given is (m,n,...), then the shape of `out` is is + (m,n,...,N). + + In other words, each entry ``out[i,j,...,:]`` is an N-dimensional + value drawn from the distribution. + +See Also +-------- +normal +scipy.stats.distributions.norm : Provides random variates, as well as + probability density function, cumulative + density function, etc. + +Notes +----- +The mean is a coordinate in N-dimensional space, which represents the +location where samples are most likely to be generated. This is +analogous to the peak of the bell curve for the one-dimensional or +univariate normal distribution. + +Covariance indicates the level to which two variables vary together. +From the multivariate normal distribution, we draw N-dimensional +samples, :math:`X = [x_1, x_2, ... x_N]`. The covariance matrix +element :math:`C_ij` is the covariance of :math:`x_i` and :math:`x_j`. +The element :math:`C_ii` is the variance of :math:`x_i` (i.e. its +"spread"). + +Instead of specifying the full covariance matrix, popular +approximations include: + + - Spherical covariance (`cov` is a multiple of the identity matrix) + - Diagonal covariance (`cov` has non-negative elements, and only on + the diagonal) + +This geometrical property can be seen in two dimensions by plotting +generated data-points: + +>>> mean = [0,0] +>>> cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis +>>> x,y = np.random.multivariate_normal(mean,cov,5000).T + +>>> import matplotlib.pyplot as plt +>>> plt.plot(x,y,'x'); plt.axis('equal'); pyplot.show() + +Note that the covariance matrix must be non-negative definite. + +References +---------- +.. [1] A. Papoulis, "Probability, Random Variables, and Stochastic + Processes," 3rd ed., McGraw-Hill Companies, 1991 +.. [2] R.O. Duda, P.E. Hart, and D.G. Stork, "Pattern Classification," + 2nd ed., Wiley, 2001. + +Examples +-------- +>>> mean = (1,2) +>>> cov = [[1,0],[1,0]] +>>> x = np.random.multivariate_normal(mean,cov,(3,3)) +>>> x.shape +(3, 3, 2) + +The following is probably true, given that 0.6 is roughly twice the +standard deviation: + +>>> print list( (x[0,0,:] - mean) < 0.6 ) +[True, True] + +.. index: + :refguide: random:distributions Modified: branches/1.1.x/numpy/doc/HOWTO_DOCUMENT.txt =================================================================== --- branches/1.1.x/numpy/doc/HOWTO_DOCUMENT.txt 2008-07-15 07:06:38 UTC (rev 5412) +++ branches/1.1.x/numpy/doc/HOWTO_DOCUMENT.txt 2008-07-15 07:38:00 UTC (rev 5413) @@ -25,15 +25,24 @@ * `pyflakes` easy_install pyflakes * `pep8.py `_ -For documentation purposes, use unabbreviated module names. If you -prefer the use of abbreviated module names in code (*not* the -docstrings), we suggest the import conventions used by NumPy itself:: +The following import conventions are used throughout the NumPy source +and documentation:: import numpy as np import scipy as sp import matplotlib as mpl import matplotlib.pyplot as plt +It is not necessary to do ``import numpy as np`` at the beginning of +an example. However, some sub-modules, such as ``fft``, are not +imported by default, and you have to include them explicitly:: + + import numpy.fft + +after which you may use it:: + + np.fft.fft2(...) + Docstring Standard ------------------ A documentation string (docstring) is a string that describes a module, @@ -65,15 +74,15 @@ A guiding principle is that human readers of the text are given precedence over contorting docstrings so our tools produce nice output. Rather than sacrificing the readability of the docstrings, we -have chosen to write pre-processors to assist tools like epydoc_ or -sphinx_ in their task. +have written pre-processors to assist tools like epydoc_ and sphinx_ in +their task. Status ------ We are busy converting existing docstrings to the new format, expanding them where they are lacking, as well as writing new ones for undocumented functions. Volunteers are welcome to join the effort on -our new wiki-based documentation system (see the `Developer Zone +our new documentation system (see the `Developer Zone `_). Sections @@ -179,6 +188,29 @@ -------- average : Weighted average + When referring to functions in the same sub-module, no prefix is + needed, and the tree is searched upwards for a match. + + Prefix functions from other sub-modules appropriately. E.g., + whilst documenting the ``random`` module, refer to a function in + ``fft`` by + + :: + + fft.fft2 : 2-D fast discrete Fourier transform + + When referring to an entirely different module:: + + scipy.random.norm : Random variates, PDFs, etc. + + Functions may be listed without descriptions:: + + See Also + -------- + func_a : Function a with its description. + func_b, func_c_, func_d + func_e + 8. **Notes** An optional section that provides additional information about the @@ -203,8 +235,14 @@ :: - The value of :math:`omega` is larger than 5. + The value of :math:`\omega` is larger than 5. + Variable names are displayed in typewriter font, obtained by using + ``\mathtt{var}``:: + + We square the input parameter `alpha` to obtain + :math:`\mathtt{alpha}^2`. + Note that LaTeX is not particularly easy to read, so use equations sparingly. @@ -277,6 +315,11 @@ b + The examples may assume that ``import numpy as np`` is executed before + the example code in *numpy*, and ``import scipy as sp`` in *scipy*. + Additional examples may make use of *matplotlib* for plotting, but should + import it explicitly, e.g., ``import matplotlib.pyplot as plt``. + 11. **Indexing tags*** Each function needs to be categorised for indexing purposes. Use @@ -286,17 +329,67 @@ :refguide: ufunc, trigonometry To index a function as a sub-category of a class, separate index - entries by a semi-colon, e.g. + entries by a colon, e.g. :: - :refguide: ufunc, numpy;reshape, other + :refguide: ufunc, numpy:reshape, other A `list of available categories `_ is available. +Documenting classes +------------------- +Class docstring +``````````````` +Use the same sections as outlined above (all except ``Returns`` are +applicable). The constructor (``__init__``) should also be documented +here. + +An ``Attributes`` section may be used to describe class variables:: + + Attributes + ---------- + x : float + The X coordinate. + y : float + The Y coordinate. + +In general, it is not necessary to list class methods. Those that are +not part of the public API have names that start with an underscore. +In some cases, however, a class may have a great many methods, of +which only a few are relevant (e.g., subclasses of ndarray). Then, it +becomes useful to have an additional ``Methods`` section:: + + class Photo(ndarray): + """ + Array with associated photographic information. + + ... + + Attributes + ---------- + exposure : float + Exposure in seconds. + + Methods + ------- + colorspace(c='rgb') + Represent the photo in the given colorspace. + gamma(n=1.0) + Change the photo's gamma exposure. + + """ + +Note that `self` is *not* listed as the first parameter of methods. + +Method docstrings +````````````````` +Document these as you would any other function. Do not include +``self`` in the list of parameters. + Common reST concepts -------------------- For paragraphs, indentation is significant and indicates indentation in the @@ -322,8 +415,9 @@ `An example `_ of the format shown here is available. Refer to `How to Build API/Reference -Documentation `_ on how to use epydoc_ or sphinx_ to -construct a manual and web page. +Documentation +`_ +on how to use epydoc_ or sphinx_ to construct a manual and web page. This document itself was written in ReStructuredText, and may be converted to HTML using:: Modified: branches/1.1.x/numpy/doc/example.py =================================================================== --- branches/1.1.x/numpy/doc/example.py 2008-07-15 07:06:38 UTC (rev 5412) +++ branches/1.1.x/numpy/doc/example.py 2008-07-15 07:38:00 UTC (rev 5413) @@ -80,7 +80,9 @@ See Also -------- otherfunc : relationship (optional) - newfunc : relationship (optional) + newfunc : Relationship (optional), which could be fairly long, in which + case the line wraps here. + thirdfunc, fourthfunc, fifthfunc Notes ----- From numpy-svn at scipy.org Tue Jul 15 04:01:38 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 03:01:38 -0500 (CDT) Subject: [Numpy-svn] r5414 - in branches/1.1.x/numpy/lib: . tests Message-ID: <20080715080138.EB9CA39C78B@scipy.org> Author: stefan Date: 2008-07-15 03:01:26 -0500 (Tue, 15 Jul 2008) New Revision: 5414 Modified: branches/1.1.x/numpy/lib/function_base.py branches/1.1.x/numpy/lib/tests/test_function_base.py Log: Merge changeset 5359:5360 from trunk. Modified: branches/1.1.x/numpy/lib/function_base.py =================================================================== --- branches/1.1.x/numpy/lib/function_base.py 2008-07-15 07:38:00 UTC (rev 5413) +++ branches/1.1.x/numpy/lib/function_base.py 2008-07-15 08:01:26 UTC (rev 5414) @@ -563,8 +563,11 @@ """ x = asanyarray(x) n2 = len(funclist) - if not isinstance(condlist, type([])): + if isscalar(condlist) or \ + not (isinstance(condlist[0], list) or + isinstance(condlist[0], ndarray)): condlist = [condlist] + condlist = [asarray(c, dtype=bool) for c in condlist] n = len(condlist) if n == n2-1: # compute the "otherwise" condition. totlist = condlist[0] @@ -573,8 +576,26 @@ condlist.append(~totlist) n += 1 if (n != n2): - raise ValueError, "function list and condition list must be the same" - y = empty(x.shape, x.dtype) + raise ValueError, "function list and condition list " \ + "must be the same" + + zerod = False + # This is a hack to work around problems with NumPy's + # handling of 0-d arrays and boolean indexing with + # numpy.bool_ scalars + if x.ndim == 0: + x = x[None] + zerod = True + newcondlist = [] + for k in range(n): + if condlist[k].ndim == 0: + condition = condlist[k][None] + else: + condition = condlist[k] + newcondlist.append(condition) + condlist = newcondlist + + y = zeros(x.shape, x.dtype) for k in range(n): item = funclist[k] if not callable(item): @@ -1072,7 +1093,7 @@ self.__doc__ = pyfunc.__doc__ else: self.__doc__ = doc - if isinstance(otypes, types.StringType): + if isinstance(otypes, str): self.otypes = otypes for char in self.otypes: if char not in typecodes['All']: @@ -1103,7 +1124,7 @@ for arg in args: newargs.append(asarray(arg).flat[0]) theout = self.thefunc(*newargs) - if isinstance(theout, types.TupleType): + if isinstance(theout, tuple): self.nout = len(theout) else: self.nout = 1 Modified: branches/1.1.x/numpy/lib/tests/test_function_base.py =================================================================== --- branches/1.1.x/numpy/lib/tests/test_function_base.py 2008-07-15 07:38:00 UTC (rev 5413) +++ branches/1.1.x/numpy/lib/tests/test_function_base.py 2008-07-15 08:01:26 UTC (rev 5414) @@ -613,6 +613,52 @@ x = array([5+6j, 1+1j, 1+10j, 10, 5+6j]) assert(all(unique(x) == [1+1j, 1+10j, 5+6j, 10])) + +class TestPiecewise(NumpyTestCase): + def check_simple(self): + # Condition is single bool list + x = piecewise([0, 0], [True, False], [1]) + assert_array_equal(x, [1, 0]) + + # List of conditions: single bool list + x = piecewise([0, 0], [[True, False]], [1]) + assert_array_equal(x, [1, 0]) + + # Conditions is single bool array + x = piecewise([0, 0], array([True, False]), [1]) + assert_array_equal(x, [1, 0]) + + # Condition is single int array + x = piecewise([0, 0], array([1, 0]), [1]) + assert_array_equal(x, [1, 0]) + + # List of conditions: int array + x = piecewise([0, 0], [array([1, 0])], [1]) + assert_array_equal(x, [1, 0]) + + + x = piecewise([0, 0], [[False, True]], [lambda x: -1]) + assert_array_equal(x, [0, -1]) + + x = piecewise([1, 2], [[True, False], [False, True]], [3, 4]) + assert_array_equal(x, [3, 4]) + + def check_default(self): + # No value specified for x[1], should be 0 + x = piecewise([1, 2], [True, False], [2]) + assert_array_equal(x, [2, 0]) + + # Should set x[1] to 3 + x = piecewise([1, 2], [True, False], [2, 3]) + assert_array_equal(x, [2, 3]) + +# def test_0d(self): +# x = array(3) +# y = piecewise(x, x>3, [4, 0]) +# assert y.ndim == 0 +# assert y == 0 + + def compare_results(res,desired): for i in range(len(desired)): assert_array_equal(res[i],desired[i]) From numpy-svn at scipy.org Tue Jul 15 04:02:23 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 03:02:23 -0500 (CDT) Subject: [Numpy-svn] r5415 - in branches/1.1.x/numpy/lib: . tests Message-ID: <20080715080223.99D3639C820@scipy.org> Author: rkern Date: 2008-07-15 03:02:21 -0500 (Tue, 15 Jul 2008) New Revision: 5415 Modified: branches/1.1.x/numpy/lib/_datasource.py branches/1.1.x/numpy/lib/tests/test__datasource.py Log: Backport r5342. Modified: branches/1.1.x/numpy/lib/_datasource.py =================================================================== --- branches/1.1.x/numpy/lib/_datasource.py 2008-07-15 08:01:26 UTC (rev 5414) +++ branches/1.1.x/numpy/lib/_datasource.py 2008-07-15 08:02:21 UTC (rev 5415) @@ -209,14 +209,14 @@ openedurl = urlopen(path) file(upath, 'w').write(openedurl.read()) except URLError: - raise URLError("URL not found: ", path) + raise URLError("URL not found: %s" % path) else: try: # TODO: Why not just copy the file with shutils.copyfile? fp = file(path, 'r') file(upath, 'w').write(fp.read()) except IOError: - raise IOError("File not found: ", path) + raise IOError("File not found: %s" % path) return upath def _findfile(self, path): Modified: branches/1.1.x/numpy/lib/tests/test__datasource.py =================================================================== --- branches/1.1.x/numpy/lib/tests/test__datasource.py 2008-07-15 08:01:26 UTC (rev 5414) +++ branches/1.1.x/numpy/lib/tests/test__datasource.py 2008-07-15 08:02:21 UTC (rev 5415) @@ -80,8 +80,17 @@ assert self.ds.open(valid_httpurl()) def test_InvalidHTTP(self): - self.assertRaises(IOError, self.ds.open, invalid_httpurl()) + url = invalid_httpurl() + self.assertRaises(IOError, self.ds.open, url) + try: + self.ds.open(url) + except IOError, e: + # Regression test for bug fixed in r4342. + assert e.errno is None + def test_InvalidHTTPCacheURLError(self): + self.assertRaises(datasource.URLError, self.ds._cache, invalid_httpurl()) + def test_ValidFile(self): local_file = valid_textfile(self.tmpdir) assert self.ds.open(local_file) From numpy-svn at scipy.org Tue Jul 15 04:03:37 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 03:03:37 -0500 (CDT) Subject: [Numpy-svn] r5416 - branches/1.1.x/numpy Message-ID: <20080715080337.28C7B39C8DB@scipy.org> Author: stefan Date: 2008-07-15 03:03:28 -0500 (Tue, 15 Jul 2008) New Revision: 5416 Modified: branches/1.1.x/numpy/__init__.py Log: Merge changeset 5292:5293 from trunk. Modified: branches/1.1.x/numpy/__init__.py =================================================================== --- branches/1.1.x/numpy/__init__.py 2008-07-15 08:02:21 UTC (rev 5415) +++ branches/1.1.x/numpy/__init__.py 2008-07-15 08:03:28 UTC (rev 5416) @@ -116,7 +116,7 @@ 'ScipyTest', 'NumpyTest', 'show_config']) __all__.extend(core.__all__) __all__.extend(lib.__all__) - __all__.extend(['linalg', 'fft', 'random', 'ctypeslib']) + __all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma']) def test(*args, **kw): import os, sys From numpy-svn at scipy.org Tue Jul 15 04:07:56 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 03:07:56 -0500 (CDT) Subject: [Numpy-svn] r5417 - in branches/1.1.x/numpy/oldnumeric: . tests Message-ID: <20080715080756.9007B39C820@scipy.org> Author: rkern Date: 2008-07-15 03:07:53 -0500 (Tue, 15 Jul 2008) New Revision: 5417 Modified: branches/1.1.x/numpy/oldnumeric/precision.py branches/1.1.x/numpy/oldnumeric/setup.py branches/1.1.x/numpy/oldnumeric/tests/test_oldnumeric.py Log: Backport r5349. Modified: branches/1.1.x/numpy/oldnumeric/precision.py =================================================================== --- branches/1.1.x/numpy/oldnumeric/precision.py 2008-07-15 08:03:28 UTC (rev 5416) +++ branches/1.1.x/numpy/oldnumeric/precision.py 2008-07-15 08:07:53 UTC (rev 5417) @@ -5,12 +5,12 @@ __all__ = ['Character', 'Complex', 'Float', 'PrecisionError', 'PyObject', 'Int', 'UInt', - 'UnsignedInteger', 'string', 'typecodes', 'zeros'] + 'UnsignedInt', 'UnsignedInteger', 'string', 'typecodes', 'zeros'] from functions import zeros import string # for backwards compatibility -typecodes = {'Character':'c', 'Integer':'bhil', 'UnsignedInteger':'BHI', 'Float':'fd', 'Complex':'FD'} +typecodes = {'Character':'c', 'Integer':'bhil', 'UnsignedInteger':'BHIL', 'Float':'fd', 'Complex':'FD'} def _get_precisions(typecodes): lst = [] @@ -67,8 +67,7 @@ __all__.extend(['UnsignedInt128', 'UInt128']) except(PrecisionError): pass -UnsignedInteger = 'u' -UInt = UnsignedInteger +UInt = UnsignedInt = UnsignedInteger = 'u' try: Int0 = _lookup(_code_table, 'Integer', 0) Modified: branches/1.1.x/numpy/oldnumeric/setup.py =================================================================== --- branches/1.1.x/numpy/oldnumeric/setup.py 2008-07-15 08:03:28 UTC (rev 5416) +++ branches/1.1.x/numpy/oldnumeric/setup.py 2008-07-15 08:07:53 UTC (rev 5417) @@ -1,7 +1,9 @@ def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - return Configuration('oldnumeric',parent_package,top_path) + config = Configuration('oldnumeric',parent_package,top_path) + config.add_data_dir('tests') + return config if __name__ == '__main__': from numpy.distutils.core import setup Modified: branches/1.1.x/numpy/oldnumeric/tests/test_oldnumeric.py =================================================================== --- branches/1.1.x/numpy/oldnumeric/tests/test_oldnumeric.py 2008-07-15 08:03:28 UTC (rev 5416) +++ branches/1.1.x/numpy/oldnumeric/tests/test_oldnumeric.py 2008-07-15 08:07:53 UTC (rev 5417) @@ -5,7 +5,7 @@ from numpy.core.numeric import float32, float64, complex64, complex128, int8, \ int16, int32, int64, uint, uint8, uint16, uint32, uint64 -class test_oldtypes(NumPyTestCase): +class test_oldtypes(NumpyTestCase): def check_oldtypes(self, level=1): a1 = array([0,1,0], Float) a2 = array([0,1,0], float) @@ -49,9 +49,13 @@ a1 = array([0,1,0], Int32) a2 = array([0,1,0], int32) assert_array_equal(a1, a2) - a1 = array([0,1,0], Int64) - a2 = array([0,1,0], int64) - assert_array_equal(a1, a2) + try: + a1 = array([0,1,0], Int64) + a2 = array([0,1,0], int64) + assert_array_equal(a1, a2) + except NameError: + # Not all systems have 64-bit integers. + pass a1 = array([0,1,0], UnsignedInt) a2 = array([0,1,0], UnsignedInteger) a3 = array([0,1,0], uint) @@ -72,15 +76,15 @@ a3 = array([0,1,0], uint32) assert_array_equal(a1, a3) assert_array_equal(a2, a3) - a1 = array([0,1,0], UInt64) - a2 = array([0,1,0], UnsignedInt64) - a3 = array([0,1,0], uint64) - assert_array_equal(a1, a3) - assert_array_equal(a2, a3) - a1 = array([0,1,0], Bool) - a2 = array([0,1,0], bool) - assert_array_equal(a1, a2) + try: + a1 = array([0,1,0], UInt64) + a2 = array([0,1,0], UnsignedInt64) + a3 = array([0,1,0], uint64) + assert_array_equal(a1, a3) + assert_array_equal(a2, a3) + except NameError: + # Not all systems have 64-bit integers. + pass - if __name__ == "__main__": - NumPyTest().run() + NumpyTest().run() From numpy-svn at scipy.org Tue Jul 15 04:11:45 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 03:11:45 -0500 (CDT) Subject: [Numpy-svn] r5418 - in branches/1.1.x/numpy/core: . tests Message-ID: <20080715081145.12CC039C627@scipy.org> Author: rkern Date: 2008-07-15 03:11:43 -0500 (Tue, 15 Jul 2008) New Revision: 5418 Modified: branches/1.1.x/numpy/core/numeric.py branches/1.1.x/numpy/core/tests/test_numeric.py Log: Backport r5357. Modified: branches/1.1.x/numpy/core/numeric.py =================================================================== --- branches/1.1.x/numpy/core/numeric.py 2008-07-15 08:07:53 UTC (rev 5417) +++ branches/1.1.x/numpy/core/numeric.py 2008-07-15 08:11:43 UTC (rev 5418) @@ -137,7 +137,7 @@ def asanyarray(a, dtype=None, order=None): """Returns a as an array, but will pass subclasses through. """ - return array(a, dtype, copy=False, order=order, subok=1) + return array(a, dtype, copy=False, order=order, subok=True) def ascontiguousarray(a, dtype=None): """Return 'a' as an array contiguous in memory (C order). @@ -182,9 +182,9 @@ return asanyarray(a, dtype=dtype) if 'ENSUREARRAY' in requirements or 'E' in requirements: - subok = 0 + subok = False else: - subok = 1 + subok = True arr = array(a, dtype=dtype, copy=False, subok=subok) @@ -344,12 +344,12 @@ nda = len(a.shape) bs = b.shape ndb = len(b.shape) - equal = 1 - if (na != nb): equal = 0 + equal = True + if (na != nb): equal = False else: for k in xrange(na): if as_[axes_a[k]] != bs[axes_b[k]]: - equal = 0 + equal = False break if axes_a[k] < 0: axes_a[k] += nda @@ -394,10 +394,10 @@ a = asanyarray(a) if axis is None: n = a.size - reshape=1 + reshape = True else: n = a.shape[axis] - reshape=0 + reshape = False shift %= n indexes = concatenate((arange(n-shift,n),arange(n-shift))) res = a.take(indexes, axis) @@ -732,10 +732,10 @@ try: a1, a2 = asarray(a1), asarray(a2) except: - return 0 + return False if a1.shape != a2.shape: - return 0 - return logical_and.reduce(equal(a1,a2).ravel()) + return False + return bool(logical_and.reduce(equal(a1,a2).ravel())) def array_equiv(a1, a2): """Returns True if a1 and a2 are shape consistent @@ -745,11 +745,11 @@ try: a1, a2 = asarray(a1), asarray(a2) except: - return 0 + return False try: - return logical_and.reduce(equal(a1,a2).ravel()) + return bool(logical_and.reduce(equal(a1,a2).ravel())) except ValueError: - return 0 + return False _errdict = {"ignore":ERR_IGNORE, Modified: branches/1.1.x/numpy/core/tests/test_numeric.py =================================================================== --- branches/1.1.x/numpy/core/tests/test_numeric.py 2008-07-15 08:07:53 UTC (rev 5417) +++ branches/1.1.x/numpy/core/tests/test_numeric.py 2008-07-15 08:11:43 UTC (rev 5418) @@ -252,6 +252,52 @@ assert_equal(binary_repr(-1), '-1') assert_equal(binary_repr(-1, width=8), '11111111') +class TestArrayComparisons(NumpyTestCase): + def test_array_equal(self): + res = array_equal(array([1,2]), array([1,2])) + assert res + assert type(res) is bool + res = array_equal(array([1,2]), array([1,2,3])) + assert not res + assert type(res) is bool + res = array_equal(array([1,2]), array([3,4])) + assert not res + assert type(res) is bool + res = array_equal(array([1,2]), array([1,3])) + assert not res + assert type(res) is bool + + def test_array_equiv(self): + res = array_equiv(array([1,2]), array([1,2])) + assert res + assert type(res) is bool + res = array_equiv(array([1,2]), array([1,2,3])) + assert not res + assert type(res) is bool + res = array_equiv(array([1,2]), array([3,4])) + assert not res + assert type(res) is bool + res = array_equiv(array([1,2]), array([1,3])) + assert not res + assert type(res) is bool + + res = array_equiv(array([1,1]), array([1])) + assert res + assert type(res) is bool + res = array_equiv(array([1,1]), array([[1],[1]])) + assert res + assert type(res) is bool + res = array_equiv(array([1,2]), array([2])) + assert not res + assert type(res) is bool + res = array_equiv(array([1,2]), array([[1],[2]])) + assert not res + assert type(res) is bool + res = array_equiv(array([1,2]), array([[1,2,3],[4,5,6],[7,8,9]])) + assert not res + assert type(res) is bool + + def assert_array_strict_equal(x, y): assert_array_equal(x, y) # Check flags From numpy-svn at scipy.org Tue Jul 15 12:22:20 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 11:22:20 -0500 (CDT) Subject: [Numpy-svn] r5419 - branches/1.1.x/numpy/testing Message-ID: <20080715162220.22664C7C02C@scipy.org> Author: dhuard Date: 2008-07-15 11:22:17 -0500 (Tue, 15 Jul 2008) New Revision: 5419 Modified: branches/1.1.x/numpy/testing/utils.py Log: backport of r5254 Modified: branches/1.1.x/numpy/testing/utils.py =================================================================== --- branches/1.1.x/numpy/testing/utils.py 2008-07-15 08:11:43 UTC (rev 5418) +++ branches/1.1.x/numpy/testing/utils.py 2008-07-15 16:22:17 UTC (rev 5419) @@ -140,7 +140,7 @@ return from numpy.core import ndarray if isinstance(actual, ndarray) or isinstance(desired, ndarray): - return assert_array_equal(actual, desired, err_msg) + return assert_array_equal(actual, desired, err_msg, verbose) msg = build_err_msg([actual, desired], err_msg, verbose=verbose) assert desired == actual, msg From numpy-svn at scipy.org Tue Jul 15 12:51:12 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 11:51:12 -0500 (CDT) Subject: [Numpy-svn] r5420 - branches/1.1.x/numpy/fft Message-ID: <20080715165112.9C12139C344@scipy.org> Author: charris Date: 2008-07-15 11:51:08 -0500 (Tue, 15 Jul 2008) New Revision: 5420 Modified: branches/1.1.x/numpy/fft/fftpack_litemodule.c Log: Backport r5406 and r5407. Modified: branches/1.1.x/numpy/fft/fftpack_litemodule.c =================================================================== --- branches/1.1.x/numpy/fft/fftpack_litemodule.c 2008-07-15 16:22:17 UTC (rev 5419) +++ branches/1.1.x/numpy/fft/fftpack_litemodule.c 2008-07-15 16:51:08 UTC (rev 5420) @@ -6,82 +6,106 @@ /* ----------------------------------------------------- */ -static char fftpack_cfftf__doc__[] =""; +static char fftpack_cfftf__doc__[] = ""; PyObject * fftpack_cfftf(PyObject *self, PyObject *args) { - PyObject *op1, *op2; - PyArrayObject *data; - double *wsave, *dptr; - int npts, nsave, nrepeats, i; + PyObject *op1, *op2; + PyArrayObject *data; + PyArray_Descr *descr; + double *wsave, *dptr; + npy_intp nsave; + int npts, nrepeats, i; - if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) return NULL; - data = (PyArrayObject *)PyArray_CopyFromObject(op1, PyArray_CDOUBLE, 1, 0); - if (data == NULL) return NULL; - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) - goto fail; - if (data == NULL) goto fail; + if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { + return NULL; + } + data = (PyArrayObject *)PyArray_CopyFromObject(op1, + PyArray_CDOUBLE, 1, 0); + if (data == NULL) { + return NULL; + } + descr = PyArray_DescrFromType(PyArray_DOUBLE); + if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) { + goto fail; + } + if (data == NULL) { + goto fail; + } - npts = data->dimensions[data->nd-1]; - if (nsave != npts*4+15) { - PyErr_SetString(ErrorObject, "invalid work array for fft size"); - goto fail; - } + npts = data->dimensions[data->nd - 1]; + if (nsave != npts*4 + 15) { + PyErr_SetString(ErrorObject, "invalid work array for fft size"); + goto fail; + } - nrepeats = PyArray_SIZE(data)/npts; - dptr = (double *)data->data; - NPY_SIGINT_ON - for (i=0; idata; + NPY_SIGINT_ON; + for (i = 0; i < nrepeats; i++) { + cfftf(npts, dptr, wsave); + dptr += npts*2; + } + NPY_SIGINT_OFF; + PyArray_Free(op2, (char *)wsave); + return (PyObject *)data; + fail: - PyArray_Free(op2, (char *)wsave); - Py_DECREF(data); - return NULL; + PyArray_Free(op2, (char *)wsave); + Py_DECREF(data); + return NULL; } -static char fftpack_cfftb__doc__[] =""; +static char fftpack_cfftb__doc__[] = ""; PyObject * fftpack_cfftb(PyObject *self, PyObject *args) { - PyObject *op1, *op2; - PyArrayObject *data; - double *wsave, *dptr; - int npts, nsave, nrepeats, i; + PyObject *op1, *op2; + PyArrayObject *data; + PyArray_Descr *descr; + double *wsave, *dptr; + npy_intp nsave; + int npts, nrepeats, i; - if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) return NULL; - data = (PyArrayObject *)PyArray_CopyFromObject(op1, PyArray_CDOUBLE, 1, 0); - if (data == NULL) return NULL; - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) - goto fail; - if (data == NULL) goto fail; + if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { + return NULL; + } + data = (PyArrayObject *)PyArray_CopyFromObject(op1, + PyArray_CDOUBLE, 1, 0); + if (data == NULL) { + return NULL; + } + descr = PyArray_DescrFromType(PyArray_DOUBLE); + if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) { + goto fail; + } + if (data == NULL) { + goto fail; + } - npts = data->dimensions[data->nd-1]; - if (nsave != npts*4+15) { - PyErr_SetString(ErrorObject, "invalid work array for fft size"); - goto fail; - } + npts = data->dimensions[data->nd - 1]; + if (nsave != npts*4 + 15) { + PyErr_SetString(ErrorObject, "invalid work array for fft size"); + goto fail; + } - nrepeats = PyArray_SIZE(data)/npts; - dptr = (double *)data->data; - NPY_SIGINT_ON - for (i=0; idata; + NPY_SIGINT_ON; + for (i = 0; i < nrepeats; i++) { + cfftb(npts, dptr, wsave); + dptr += npts*2; + } + NPY_SIGINT_OFF; + PyArray_Free(op2, (char *)wsave); + return (PyObject *)data; + fail: - PyArray_Free(op2, (char *)wsave); - Py_DECREF(data); - return NULL; + PyArray_Free(op2, (char *)wsave); + Py_DECREF(data); + return NULL; } static char fftpack_cffti__doc__[] =""; @@ -89,21 +113,26 @@ static PyObject * fftpack_cffti(PyObject *self, PyObject *args) { - PyArrayObject *op; - int dim, n; + PyArrayObject *op; + npy_intp dim; + long n; - if (!PyArg_ParseTuple(args, "i", &n)) return NULL; + if (!PyArg_ParseTuple(args, "l", &n)) { + return NULL; + } + /*Magic size needed by cffti*/ + dim = 4*n + 15; + /*Create a 1 dimensional array of dimensions of type double*/ + op = (PyArrayObject *)PyArray_SimpleNew(1, &dim, PyArray_DOUBLE); + if (op == NULL) { + return NULL; + } - dim = 4*n+15; /*Magic size needed by cffti*/ - /*Create a 1 dimensional array of dimensions of type double*/ - op = (PyArrayObject *)PyArray_FromDims(1, &dim, PyArray_DOUBLE); - if (op == NULL) return NULL; + NPY_SIGINT_ON; + cffti(n, (double *)((PyArrayObject*)op)->data); + NPY_SIGINT_OFF; - NPY_SIGINT_ON - cffti(n, (double *)((PyArrayObject*)op)->data); - NPY_SIGINT_OFF - - return (PyObject *)op; + return (PyObject *)op; } static char fftpack_rfftf__doc__[] =""; @@ -111,53 +140,64 @@ PyObject * fftpack_rfftf(PyObject *self, PyObject *args) { - PyObject *op1, *op2; - PyArrayObject *data, *ret; - double *wsave, *dptr, *rptr; - int npts, nsave, nrepeats, i, rstep; + PyObject *op1, *op2; + PyArrayObject *data, *ret; + PyArray_Descr *descr; + double *wsave, *dptr, *rptr; + npy_intp nsave; + int npts, nrepeats, i, rstep; - if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) return NULL; - data = (PyArrayObject *)PyArray_ContiguousFromObject(op1, PyArray_DOUBLE, 1, 0); - if (data == NULL) return NULL; - npts = data->dimensions[data->nd-1]; - data->dimensions[data->nd-1] = npts/2+1; - ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, - PyArray_DescrFromType(PyArray_CDOUBLE), 0); - data->dimensions[data->nd-1] = npts; - rstep = (ret->dimensions[ret->nd-1])*2; + if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { + return NULL; + } + data = (PyArrayObject *)PyArray_ContiguousFromObject(op1, + PyArray_DOUBLE, 1, 0); + if (data == NULL) { + return NULL; + } + npts = data->dimensions[data->nd-1]; + data->dimensions[data->nd - 1] = npts/2 + 1; + ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, + PyArray_DescrFromType(PyArray_CDOUBLE), 0); + data->dimensions[data->nd - 1] = npts; + rstep = (ret->dimensions[ret->nd - 1])*2; - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) - goto fail; - if (data == NULL || ret == NULL) goto fail; + descr = PyArray_DescrFromType(PyArray_DOUBLE); + if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) { + goto fail; + } + if (data == NULL || ret == NULL) { + goto fail; + } + if (nsave != npts*2+15) { + PyErr_SetString(ErrorObject, "invalid work array for fft size"); + goto fail; + } - if (nsave != npts*2+15) { - PyErr_SetString(ErrorObject, "invalid work array for fft size"); - goto fail; - } + nrepeats = PyArray_SIZE(data)/npts; + rptr = (double *)ret->data; + dptr = (double *)data->data; - nrepeats = PyArray_SIZE(data)/npts; - rptr = (double *)ret->data; - dptr = (double *)data->data; + NPY_SIGINT_ON; + for (i = 0; i < nrepeats; i++) { + memcpy((char *)(rptr+1), dptr, npts*sizeof(double)); + rfftf(npts, rptr+1, wsave); + rptr[0] = rptr[1]; + rptr[1] = 0.0; + rptr += rstep; + dptr += npts; + } + NPY_SIGINT_OFF; + PyArray_Free(op2, (char *)wsave); + Py_DECREF(data); + return (PyObject *)ret; - NPY_SIGINT_ON - for (i=0; idimensions[data->nd-1]; - ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, - PyArray_DescrFromType(PyArray_DOUBLE), 0); + if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) { + return NULL; + } + data = (PyArrayObject *)PyArray_ContiguousFromObject(op1, + PyArray_CDOUBLE, 1, 0); + if (data == NULL) { + return NULL; + } + npts = data->dimensions[data->nd - 1]; + ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions, + PyArray_DescrFromType(PyArray_DOUBLE), 0); - if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) - goto fail; - if (data == NULL || ret == NULL) goto fail; + descr = PyArray_DescrFromType(PyArray_DOUBLE); + if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) { + goto fail; + } + if (data == NULL || ret == NULL) { + goto fail; + } + if (nsave != npts*2 + 15) { + PyErr_SetString(ErrorObject, "invalid work array for fft size"); + goto fail; + } - if (nsave != npts*2+15) { - PyErr_SetString(ErrorObject, "invalid work array for fft size"); - goto fail; - } + nrepeats = PyArray_SIZE(ret)/npts; + rptr = (double *)ret->data; + dptr = (double *)data->data; - nrepeats = PyArray_SIZE(ret)/npts; - rptr = (double *)ret->data; - dptr = (double *)data->data; + NPY_SIGINT_ON; + for (i = 0; i < nrepeats; i++) { + memcpy((char *)(rptr + 1), (dptr + 2), (npts - 1)*sizeof(double)); + rptr[0] = dptr[0]; + rfftb(npts, rptr, wsave); + rptr += npts; + dptr += npts*2; + } + NPY_SIGINT_OFF; + PyArray_Free(op2, (char *)wsave); + Py_DECREF(data); + return (PyObject *)ret; - NPY_SIGINT_ON - for (i=0; idata); - NPY_SIGINT_OFF + NPY_SIGINT_OFF; return (PyObject *)op; } @@ -237,13 +292,13 @@ /* List of methods defined in the module */ static struct PyMethodDef fftpack_methods[] = { - {"cfftf", fftpack_cfftf, 1, fftpack_cfftf__doc__}, - {"cfftb", fftpack_cfftb, 1, fftpack_cfftb__doc__}, - {"cffti", fftpack_cffti, 1, fftpack_cffti__doc__}, - {"rfftf", fftpack_rfftf, 1, fftpack_rfftf__doc__}, - {"rfftb", fftpack_rfftb, 1, fftpack_rfftb__doc__}, - {"rffti", fftpack_rffti, 1, fftpack_rffti__doc__}, - {NULL, NULL} /* sentinel */ + {"cfftf", fftpack_cfftf, 1, fftpack_cfftf__doc__}, + {"cfftb", fftpack_cfftb, 1, fftpack_cfftb__doc__}, + {"cffti", fftpack_cffti, 1, fftpack_cffti__doc__}, + {"rfftf", fftpack_rfftf, 1, fftpack_rfftf__doc__}, + {"rfftb", fftpack_rfftb, 1, fftpack_rfftb__doc__}, + {"rffti", fftpack_rffti, 1, fftpack_rffti__doc__}, + {NULL, NULL} /* sentinel */ }; @@ -255,21 +310,21 @@ PyMODINIT_FUNC initfftpack_lite(void) { - PyObject *m, *d; + PyObject *m, *d; - /* Create the module and add the functions */ - m = Py_InitModule4("fftpack_lite", fftpack_methods, - fftpack_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); + /* Create the module and add the functions */ + m = Py_InitModule4("fftpack_lite", fftpack_methods, + fftpack_module_documentation, + (PyObject*)NULL,PYTHON_API_VERSION); - /* Import the array object */ - import_array(); + /* Import the array object */ + import_array(); - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - ErrorObject = PyErr_NewException("fftpack.error", NULL, NULL); - PyDict_SetItemString(d, "error", ErrorObject); + /* Add some symbolic constants to the module */ + d = PyModule_GetDict(m); + ErrorObject = PyErr_NewException("fftpack.error", NULL, NULL); + PyDict_SetItemString(d, "error", ErrorObject); - /* XXXX Add constants here */ + /* XXXX Add constants here */ } From numpy-svn at scipy.org Tue Jul 15 13:02:09 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 12:02:09 -0500 (CDT) Subject: [Numpy-svn] r5421 - branches/1.1.x/numpy/core/src Message-ID: <20080715170209.935B739C5E5@scipy.org> Author: charris Date: 2008-07-15 12:02:04 -0500 (Tue, 15 Jul 2008) New Revision: 5421 Modified: branches/1.1.x/numpy/core/src/arrayobject.c branches/1.1.x/numpy/core/src/ufuncobject.c Log: Backport r5399. Modified: branches/1.1.x/numpy/core/src/arrayobject.c =================================================================== --- branches/1.1.x/numpy/core/src/arrayobject.c 2008-07-15 16:51:08 UTC (rev 5420) +++ branches/1.1.x/numpy/core/src/arrayobject.c 2008-07-15 17:02:04 UTC (rev 5421) @@ -4342,7 +4342,7 @@ if (repr) { if (PyArray_ISEXTENDED(self)) { char buf[100]; - snprintf(buf, sizeof(buf), "%d", self->descr->elsize); + PyOS_snprintf(buf, sizeof(buf), "%d", self->descr->elsize); sprintf(string+n, ", '%c%s')", self->descr->type, buf); ret = PyString_FromStringAndSize(string, n+6+strlen(buf)); } @@ -7339,7 +7339,7 @@ if (PyCObject_Check(ip)) { inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip); if (inter->two == 2) { - snprintf(buf, 40, "|%c%d", inter->typekind, + PyOS_snprintf(buf, 40, "|%c%d", inter->typekind, inter->itemsize); chktype = _array_typedescr_fromstr(buf); } @@ -8520,7 +8520,8 @@ } if (thetype == NULL) { - snprintf(buf, 40, "%c%c%d", endian, inter->typekind, inter->itemsize); + PyOS_snprintf(buf, 40, + "%c%c%d", endian, inter->typekind, inter->itemsize); if (!(thetype=_array_typedescr_fromstr(buf))) { Py_DECREF(attr); return NULL; Modified: branches/1.1.x/numpy/core/src/ufuncobject.c =================================================================== --- branches/1.1.x/numpy/core/src/ufuncobject.c 2008-07-15 16:51:08 UTC (rev 5420) +++ branches/1.1.x/numpy/core/src/ufuncobject.c 2008-07-15 17:02:04 UTC (rev 5421) @@ -670,7 +670,8 @@ switch(method) { case UFUNC_ERR_WARN: - snprintf(msg, 100, "%s encountered in %s", errtype, name); + PyOS_snprintf(msg, sizeof(msg), + "%s encountered in %s", errtype, name); if (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail; break; case UFUNC_ERR_RAISE: @@ -714,7 +715,8 @@ errtype, name); goto fail; } - snprintf(msg, 100, "Warning: %s encountered in %s\n", errtype, name); + PyOS_snprintf(msg, sizeof(msg), + "Warning: %s encountered in %s\n", errtype, name); ret = PyObject_CallMethod(pyfunc, "write", "s", msg); if (ret == NULL) goto fail; Py_DECREF(ret); From numpy-svn at scipy.org Tue Jul 15 13:42:52 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 12:42:52 -0500 (CDT) Subject: [Numpy-svn] r5422 - trunk/numpy/testing Message-ID: <20080715174252.CCC08C7C025@scipy.org> Author: alan.mcintyre Date: 2008-07-15 12:42:50 -0500 (Tue, 15 Jul 2008) New Revision: 5422 Modified: trunk/numpy/testing/utils.py Log: Added isfunction and decorate_methods in support of SciPy switching to use numpy.testing. Modified: trunk/numpy/testing/utils.py =================================================================== --- trunk/numpy/testing/utils.py 2008-07-15 17:02:04 UTC (rev 5421) +++ trunk/numpy/testing/utils.py 2008-07-15 17:42:50 UTC (rev 5422) @@ -7,12 +7,14 @@ import re import difflib import operator +from inspect import isfunction from nosetester import import_nose __all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal', 'assert_array_equal', 'assert_array_less', 'assert_string_equal', 'assert_array_almost_equal', 'assert_raises', 'build_err_msg', - 'jiffies', 'memusage', 'raises', 'rand', 'rundocs', 'runstring'] + 'decorate_methods', 'jiffies', 'memusage', 'raises', 'rand', + 'rundocs', 'runstring'] def rand(*args): """Returns an array of random numbers with the given shape. @@ -327,3 +329,37 @@ def assert_raises(*args,**kwargs): nose = import_nose() return nose.tools.assert_raises(*args,**kwargs) + +def decorate_methods(cls, decorator, testmatch=None): + ''' Apply decorator to all methods in class matching testmatch + + Parameters + ---------- + cls : class + Class to decorate methods for + decorator : function + Decorator to apply to methods + testmatch : compiled regexp or string to compile to regexp + Decorators are applied if testmatch.search(methodname) + is not None. Default value is + re.compile(r'(?:^|[\\b_\\.%s-])[Tt]est' % os.sep) + (the default for nose) + ''' + if testmatch is None: + testmatch = re.compile(r'(?:^|[\\b_\\.%s-])[Tt]est' % os.sep) + else: + testmatch = re.compile(testmatch) + cls_attr = cls.__dict__ + methods = filter(isfunction, cls_attr.values()) + for function in methods: + try: + if hasattr(function, 'compat_func_name'): + funcname = function.compat_func_name + else: + funcname = function.__name__ + except AttributeError: + # not a function + continue + if testmatch.search(funcname) and not funcname.startswith('_'): + setattr(cls, funcname, decorator(function)) + return From numpy-svn at scipy.org Tue Jul 15 17:49:50 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 16:49:50 -0500 (CDT) Subject: [Numpy-svn] r5423 - in branches/1.1.x/numpy/ma: . tests Message-ID: <20080715214950.F1AA9C7C077@scipy.org> Author: pierregm Date: 2008-07-15 16:49:36 -0500 (Tue, 15 Jul 2008) New Revision: 5423 Modified: branches/1.1.x/numpy/ma/core.py branches/1.1.x/numpy/ma/mrecords.py branches/1.1.x/numpy/ma/tests/test_core.py branches/1.1.x/numpy/ma/tests/test_mrecords.py Log: * improved support for flexible dtypes (w/ nesting and shaped fields) Modified: branches/1.1.x/numpy/ma/core.py =================================================================== --- branches/1.1.x/numpy/ma/core.py 2008-07-15 17:42:50 UTC (rev 5422) +++ branches/1.1.x/numpy/ma/core.py 2008-07-15 21:49:36 UTC (rev 5423) @@ -125,7 +125,10 @@ if hasattr(obj,'dtype'): defval = default_filler[obj.dtype.kind] elif isinstance(obj, np.dtype): - defval = default_filler[obj.kind] + if obj.subdtype: + defval = default_filler[obj.subdtype[0].kind] + else: + defval = default_filler[obj.kind] elif isinstance(obj, float): defval = default_filler['f'] elif isinstance(obj, int) or isinstance(obj, long): @@ -184,19 +187,28 @@ def _check_fill_value(fill_value, dtype): - descr = np.dtype(dtype).descr + ndtype = np.dtype(dtype) + fields = ndtype.fields if fill_value is None: - if len(descr) > 1: - fill_value = [default_fill_value(np.dtype(d[1])) - for d in descr] + if fields: + fill_value = [default_fill_value(fields[n][0]) + for n in ndtype.names] else: - fill_value = default_fill_value(dtype) + fill_value = default_fill_value(ndtype) else: fill_value = np.array(fill_value).tolist() - fval = np.resize(fill_value, len(descr)) - if len(descr) > 1: - fill_value = [np.asarray(f).astype(d[1]).item() - for (f,d) in zip(fval, descr)] + fval = np.resize(fill_value, len(ndtype.descr)) + if fields: + fill_value = [] + for (f, n) in zip(fval, ndtype.names): + current = fields[n][0] + if current.subdtype: + fill_value.append(np.asarray(f).astype(current.subdtype[0])) + else: + fill_value.append(np.asarray(f).astype(current)) +# +# fill_value = [np.asarray(f).astype(fields[n][0]).item() +# for (f, n) in zip(fval, ndtype.names)] else: fill_value = np.array(fval, copy=False, dtype=dtype).item() return fill_value @@ -1147,7 +1159,9 @@ Value used to fill in the masked values when necessary. If None, a default based on the datatype is used. keep_mask : {True, boolean} - Whether to combine mask with the mask of the input data, + Whether to combine m + x = mrecarray(1, formats="(2,2)f8") + assert_equal(x.fill_value, ma.default_fill_value(np.dtype(float)))ask with the mask of the input data, if any (True), or to use only mask for the output (False). hard_mask : {False, boolean} Whether to use a hard mask or not. With a hard mask, @@ -3750,3 +3764,5 @@ zeros = _convert2ma('zeros') ############################################################################### +if __name__ == '__main__': + x = array((1,), dtype=[('f0', ' 1: - return self._fieldmask.view((bool_, len(self.dtype))).all(1) + fieldmask = ndarray.__getattribute__(self, '_fieldmask') + if fieldmask.size > 1: + axis = 1 else: - return self._fieldmask.view((bool_, len(self.dtype))).all() + axis=None + try: + return fieldmask.view((bool_, len(self.dtype))).all(axis) + except ValueError: + return np.all([[f[n].all() for n in fieldmask.dtype.names] + for f in fieldmask], axis=axis) mask = _mask = property(fget=_getmask, fset=_setmask) #...................................................... def get_fill_value(self): @@ -224,7 +238,11 @@ if self._fill_value is None: ddtype = self.dtype fillval = _check_fill_value(None, ddtype) - self._fill_value = np.array(tuple(fillval), dtype=ddtype) + # We can't use ddtype to reconstruct the array as we don't need... + # ... the shape of the fields + self._fill_value = np.array(tuple(fillval), + dtype=zip(ddtype.names, + (_[1] for _ in ddtype.descr))) return self._fill_value def set_fill_value(self, value=None): @@ -421,7 +439,7 @@ """ _localdict = self.__dict__ - d = self._data + d = ndarray.__getattribute__(self, '_data') fm = _localdict['_fieldmask'] if not np.asarray(fm, dtype=bool_).any(): return d @@ -437,7 +455,7 @@ result = np.asanyarray(value) else: result = d.copy() - for (n, v) in zip(d.dtype.names, value): + for (n, v) in zip(fm.dtype.names, value): np.putmask(np.asarray(result[n]), np.asarray(fm[n]), v) return result #...................................................... @@ -776,3 +794,15 @@ return newdata ############################################################################### +if __name__ == '__main__': + from numpy.ma.testutils import assert_equal + + if 1: + ilist = [1,2,3,4,5] + flist = [1.1,2.2,3.3,4.4,5.5] + slist = ['one','two','three','four','five'] + ddtype = [('a',int),('b',float),('c','|S8')] + mask = [0,1,0,0,1] + base = ma.array(zip(ilist,flist,slist), mask=mask, dtype=ddtype) + mbase = base.view(mrecarray) + mbase._mask = nomask \ No newline at end of file Modified: branches/1.1.x/numpy/ma/tests/test_core.py =================================================================== --- branches/1.1.x/numpy/ma/tests/test_core.py 2008-07-15 17:42:50 UTC (rev 5422) +++ branches/1.1.x/numpy/ma/tests/test_core.py 2008-07-15 21:49:36 UTC (rev 5423) @@ -792,7 +792,7 @@ series = data[[0,2,1]] assert_equal(series._fill_value, data._fill_value) # - mtype = [('f',float_),('s','|S3')] + mtype = [('f',float),('s','|S3')] x = array([(1,'a'),(2,'b'),(numpy.pi,'pi')], dtype=mtype) x.fill_value=999 assert_equal(x.fill_value,[999.,'999']) Modified: branches/1.1.x/numpy/ma/tests/test_mrecords.py =================================================================== --- branches/1.1.x/numpy/ma/tests/test_mrecords.py 2008-07-15 17:42:50 UTC (rev 5422) +++ branches/1.1.x/numpy/ma/tests/test_mrecords.py 2008-07-15 21:49:36 UTC (rev 5423) @@ -270,6 +270,31 @@ # assert_equal(mrec.tolist(), [(1,1.1,None),(2,2.2,'two'),(None,None,'three')]) + # + def test_withnames(self): + "Test the creation w/ format and names" + x = mrecarray(1, formats=float, names='base') + x[0]['base'] = 10 + assert_equal(x['base'][0], 10) + # + def test_exotic_formats(self): + "Test that 'exotic' formats are processed properly" + easy = mrecarray(1, dtype=[('i',int), ('s','|S3'), ('f',float)]) + easy[0] = masked + easy.filled(1) + assert_equal(easy.filled(1).item(), (1,'1',1.)) + # + solo = mrecarray(1, dtype=[('f0', ' Author: alan.mcintyre Date: 2008-07-15 19:36:32 -0500 (Tue, 15 Jul 2008) New Revision: 5424 Modified: trunk/numpy/testing/utils.py Log: Added the measure function to utils.py in support of SciPy tests. Modified: trunk/numpy/testing/utils.py =================================================================== --- trunk/numpy/testing/utils.py 2008-07-15 21:49:36 UTC (rev 5423) +++ trunk/numpy/testing/utils.py 2008-07-16 00:36:32 UTC (rev 5424) @@ -363,3 +363,22 @@ if testmatch.search(funcname) and not funcname.startswith('_'): setattr(cls, funcname, decorator(function)) return + + +def measure(code_str,times=1,label=None): + """ Return elapsed time for executing code_str in the + namespace of the caller for given times. + """ + frame = sys._getframe(1) + locs,globs = frame.f_locals,frame.f_globals + + code = compile(code_str, + 'Test name: %s ' % label, + 'exec') + i = 0 + elapsed = jiffies() + while i Author: charris Date: 2008-07-15 22:07:22 -0500 (Tue, 15 Jul 2008) New Revision: 5425 Modified: branches/1.1.x/numpy/lib/format.py Log: Backport r5324 and r5320 by copying format.py from trunk. Modified: branches/1.1.x/numpy/lib/format.py =================================================================== --- branches/1.1.x/numpy/lib/format.py 2008-07-16 00:36:32 UTC (rev 5424) +++ branches/1.1.x/numpy/lib/format.py 2008-07-16 03:07:22 UTC (rev 5425) @@ -1,12 +1,14 @@ -""" Define a simple format for saving numpy arrays to disk with the full +"""Define a simple format for saving numpy arrays to disk. + +Define a simple format for saving numpy arrays to disk with the full information about them. WARNING: Due to limitations in the interpretation of structured dtypes, dtypes with fields with empty names will have the names replaced by 'f0', 'f1', etc. -Such arrays will not round-trip through the format entirely accurately. The data -is intact; only the field names will differ. We are working on a fix for this. -This fix will not require a change in the file format. The arrays with such -structures can still be saved and restored, and the correct dtype may be +Such arrays will not round-trip through the format entirely accurately. The +data is intact; only the field names will differ. We are working on a fix for +this. This fix will not require a change in the file format. The arrays with +such structures can still be saved and restored, and the correct dtype may be restored by using the `loadedarray.view(correct_dtype)` method. Format Version 1.0 @@ -24,11 +26,11 @@ The next 2 bytes form a little-endian unsigned short int: the length of the header data HEADER_LEN. -The next HEADER_LEN bytes form the header data describing the array's format. It -is an ASCII string which contains a Python literal expression of a dictionary. -It is terminated by a newline ('\\n') and padded with spaces ('\\x20') to make -the total length of the magic string + 4 + HEADER_LEN be evenly divisible by 16 -for alignment purposes. +The next HEADER_LEN bytes form the header data describing the array's format. +It is an ASCII string which contains a Python literal expression of a +dictionary. It is terminated by a newline ('\\n') and padded with spaces +('\\x20') to make the total length of the magic string + 4 + HEADER_LEN be +evenly divisible by 16 for alignment purposes. The dictionary contains three keys: @@ -43,8 +45,8 @@ The shape of the array. For repeatability and readability, the dictionary keys are sorted in alphabetic -order. This is for convenience only. A writer SHOULD implement this if possible. -A reader MUST NOT depend on this. +order. This is for convenience only. A writer SHOULD implement this if +possible. A reader MUST NOT depend on this. Following the header comes the array data. If the dtype contains Python objects (i.e. dtype.hasobject is True), then the data is a Python pickle of the array. @@ -52,6 +54,7 @@ fortran_order) bytes of the array. Consumers can figure out the number of bytes by multiplying the number of elements given by the shape (noting that shape=() means there is 1 element) by dtype.itemsize. + """ import cPickle @@ -112,10 +115,11 @@ """ Get a serializable descriptor from the dtype. The .descr attribute of a dtype object cannot be round-tripped through the - dtype() constructor. Simple types, like dtype('float32'), have a descr which - looks like a record array with one field with '' as a name. The dtype() - constructor interprets this as a request to give a default name. Instead, we - construct descriptor that can be passed to dtype(). + dtype() constructor. Simple types, like dtype('float32'), have a descr + which looks like a record array with one field with '' as a name. The + dtype() constructor interprets this as a request to give a default name. + Instead, we construct descriptor that can be passed to dtype(). + """ if dtype.names is not None: # This is a record array. The .descr is fine. @@ -164,15 +168,16 @@ This has the appropriate entries for writing its string representation to the header of the file. """ - header = "{" + header = ["{"] for key, value in sorted(d.items()): # Need to use repr here, since we eval these when reading - header += "'%s': %s, " % (key, repr(value)) - header += "}" - # Pad the header with spaces and a final newline such that the magic string, - # the header-length short and the header are aligned on a 16-byte boundary. - # Hopefully, some system, possibly memory-mapping, can take advantage of - # our premature optimization. + header.append("'%s': %s, " % (key, repr(value))) + header.append("}") + header = "".join(header) + # Pad the header with spaces and a final newline such that the magic + # string, the header-length short and the header are aligned on a 16-byte + # boundary. Hopefully, some system, possibly memory-mapping, can take + # advantage of our premature optimization. current_header_len = MAGIC_LEN + 2 + len(header) + 1 # 1 for the newline topad = 16 - (current_header_len % 16) header = '%s%s\n' % (header, ' '*topad) @@ -210,7 +215,8 @@ # header. hlength_str = fp.read(2) if len(hlength_str) != 2: - raise ValueError("EOF at %s before reading array header length" % fp.tell()) + msg = "EOF at %s before reading array header length" + raise ValueError(msg % fp.tell()) header_length = struct.unpack(' Author: charris Date: 2008-07-15 22:10:52 -0500 (Tue, 15 Jul 2008) New Revision: 5426 Modified: branches/1.1.x/numpy/core/src/arraytypes.inc.src Log: Backport r5392 by copying function PyArray_DescrFromType from trunk. Modified: branches/1.1.x/numpy/core/src/arraytypes.inc.src =================================================================== --- branches/1.1.x/numpy/core/src/arraytypes.inc.src 2008-07-16 03:07:22 UTC (rev 5425) +++ branches/1.1.x/numpy/core/src/arraytypes.inc.src 2008-07-16 03:10:52 UTC (rev 5426) @@ -2476,46 +2476,56 @@ static PyArray_Descr * PyArray_DescrFromType(int type) { - PyArray_Descr *ret=NULL; + PyArray_Descr *ret = NULL; if (type < PyArray_NTYPES) { ret = _builtin_descrs[type]; } else if (type == PyArray_NOTYPE) { - /* This needs to not raise an error so - that PyArray_DescrFromType(PyArray_NOTYPE) - works for backwards-compatible C-API + /* + * This needs to not raise an error so + * that PyArray_DescrFromType(PyArray_NOTYPE) + * works for backwards-compatible C-API */ return NULL; } - else if ((type == PyArray_CHAR) || \ - (type == PyArray_CHARLTR)) { + else if ((type == PyArray_CHAR) || (type == PyArray_CHARLTR)) { ret = PyArray_DescrNew(_builtin_descrs[PyArray_STRING]); + + if (ret == NULL) { + return NULL; + } ret->elsize = 1; ret->type = PyArray_CHARLTR; return ret; } - else if PyTypeNum_ISUSERDEF(type) { - ret = userdescrs[type-PyArray_USERDEF]; + else if (PyTypeNum_ISUSERDEF(type)) { + ret = userdescrs[type - PyArray_USERDEF]; } else { - int num=PyArray_NTYPES; - if (type < _MAX_LETTER) + int num = PyArray_NTYPES; + if (type < _MAX_LETTER) { num = (int) _letter_to_num[type]; - if (num >= PyArray_NTYPES) + } + if (num >= PyArray_NTYPES) { ret = NULL; - else + } + else { ret = _builtin_descrs[num]; + } } - if (ret==NULL) { + if (ret == NULL) { PyErr_SetString(PyExc_ValueError, "Invalid data-type for array"); } - else Py_INCREF(ret); + else { + Py_INCREF(ret); + } return ret; } + static int set_typeinfo(PyObject *dict) { From numpy-svn at scipy.org Tue Jul 15 23:15:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 22:15:30 -0500 (CDT) Subject: [Numpy-svn] r5427 - branches/1.1.x/numpy/core/src Message-ID: <20080716031530.91F5539C088@scipy.org> Author: charris Date: 2008-07-15 22:15:22 -0500 (Tue, 15 Jul 2008) New Revision: 5427 Modified: branches/1.1.x/numpy/core/src/ufuncobject.c Log: Backport r5312 by copying _has_reflected_op from trunk. Modified: branches/1.1.x/numpy/core/src/ufuncobject.c =================================================================== --- branches/1.1.x/numpy/core/src/ufuncobject.c 2008-07-16 03:10:52 UTC (rev 5426) +++ branches/1.1.x/numpy/core/src/ufuncobject.c 2008-07-16 03:15:22 UTC (rev 5427) @@ -1285,22 +1285,23 @@ static int _has_reflected_op(PyObject *op, char *name) { - _GETATTR_(add, radd) - _GETATTR_(subtract, rsub) - _GETATTR_(multiply, rmul) - _GETATTR_(divide, rdiv) - _GETATTR_(true_divide, rtruediv) - _GETATTR_(floor_divide, rfloordiv) - _GETATTR_(remainder, rmod) - _GETATTR_(power, rpow) - _GETATTR_(left_shift, rrlshift) - _GETATTR_(right_shift, rrshift) - _GETATTR_(bitwise_and, rand) - _GETATTR_(bitwise_xor, rxor) - _GETATTR_(bitwise_or, ror) - return 0; + _GETATTR_(add, radd); + _GETATTR_(subtract, rsub); + _GETATTR_(multiply, rmul); + _GETATTR_(divide, rdiv); + _GETATTR_(true_divide, rtruediv); + _GETATTR_(floor_divide, rfloordiv); + _GETATTR_(remainder, rmod); + _GETATTR_(power, rpow); + _GETATTR_(left_shift, rlshift); + _GETATTR_(right_shift, rrshift); + _GETATTR_(bitwise_and, rand); + _GETATTR_(bitwise_xor, rxor); + _GETATTR_(bitwise_or, ror); + return 0; } + #undef _GETATTR_ static Py_ssize_t From numpy-svn at scipy.org Tue Jul 15 23:21:11 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 22:21:11 -0500 (CDT) Subject: [Numpy-svn] r5428 - branches/1.1.x/numpy/core/src Message-ID: <20080716032111.40C33C7C026@scipy.org> Author: charris Date: 2008-07-15 22:21:08 -0500 (Tue, 15 Jul 2008) New Revision: 5428 Modified: branches/1.1.x/numpy/core/src/ufuncobject.c Log: Backport r5245. Modified: branches/1.1.x/numpy/core/src/ufuncobject.c =================================================================== --- branches/1.1.x/numpy/core/src/ufuncobject.c 2008-07-16 03:15:22 UTC (rev 5427) +++ branches/1.1.x/numpy/core/src/ufuncobject.c 2008-07-16 03:21:08 UTC (rev 5428) @@ -2745,7 +2745,7 @@ while(loop->index < loop->size) { if (loop->obj) Py_INCREF(*((PyObject **)loop->it->dataptr)); - memcpy(loop->bufptr[0], loop->it->dataptr, + memmove(loop->bufptr[0], loop->it->dataptr, loop->outsize); PyArray_ITER_NEXT(loop->it); loop->bufptr[0] += loop->outsize; @@ -2758,7 +2758,7 @@ /* Copy first element to output */ if (loop->obj) Py_INCREF(*((PyObject **)loop->it->dataptr)); - memcpy(loop->bufptr[0], loop->it->dataptr, + memmove(loop->bufptr[0], loop->it->dataptr, loop->outsize); /* Adjust input pointer */ loop->bufptr[1] = loop->it->dataptr+loop->steps[1]; From numpy-svn at scipy.org Tue Jul 15 23:33:20 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 15 Jul 2008 22:33:20 -0500 (CDT) Subject: [Numpy-svn] r5429 - branches/1.1.x/numpy/core/src Message-ID: <20080716033320.1C8B439C088@scipy.org> Author: charris Date: 2008-07-15 22:33:12 -0500 (Tue, 15 Jul 2008) New Revision: 5429 Modified: branches/1.1.x/numpy/core/src/arrayobject.c Log: Backport r5255 by copy _zerofill and array_imag_get from trunk. Modified: branches/1.1.x/numpy/core/src/arrayobject.c =================================================================== --- branches/1.1.x/numpy/core/src/arrayobject.c 2008-07-16 03:21:08 UTC (rev 5428) +++ branches/1.1.x/numpy/core/src/arrayobject.c 2008-07-16 03:33:12 UTC (rev 5429) @@ -6640,6 +6640,27 @@ } } + +static int +_zerofill(PyArrayObject *ret) +{ + if (PyDataType_REFCHK(ret->descr)) { + PyObject *zero = PyInt_FromLong(0); + PyArray_FillObjectArray(ret, zero); + Py_DECREF(zero); + if (PyErr_Occurred()) { + Py_DECREF(ret); + return -1; + } + } + else { + intp n = PyArray_NBYTES(ret); + memset(ret->data, 0, n); + } + return 0; +} + + /* Create a view of a complex array with an equivalent data-type except it is real instead of complex. */ @@ -6721,29 +6742,26 @@ array_imag_get(PyArrayObject *self) { PyArrayObject *ret; - PyArray_Descr *type; if (PyArray_ISCOMPLEX(self)) { ret = _get_part(self, 1); - return (PyObject *) ret; } else { - type = self->descr; - Py_INCREF(type); - ret = (PyArrayObject *)PyArray_Zeros(self->nd, - self->dimensions, - type, - PyArray_ISFORTRAN(self)); + Py_INCREF(self->descr); + ret = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, + self->descr, + self->nd, + self->dimensions, + NULL, NULL, + PyArray_ISFORTRAN(self), + (PyObject *)self); + if (ret == NULL) return NULL; + + if (_zerofill(ret) < 0) return NULL; + ret->flags &= ~WRITEABLE; - if (PyArray_CheckExact(self)) - return (PyObject *)ret; - else { - PyObject *newret; - newret = PyArray_View(ret, NULL, self->ob_type); - Py_DECREF(ret); - return newret; - } } + return (PyObject *) ret; } static int From numpy-svn at scipy.org Wed Jul 16 01:39:03 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 00:39:03 -0500 (CDT) Subject: [Numpy-svn] r5430 - trunk/numpy/core/src Message-ID: <20080716053903.182F439C1A6@scipy.org> Author: charris Date: 2008-07-16 00:38:55 -0500 (Wed, 16 Jul 2008) New Revision: 5430 Modified: trunk/numpy/core/src/multiarraymodule.c Log: Deprecate PyArray_As2D. Modified: trunk/numpy/core/src/multiarraymodule.c =================================================================== --- trunk/numpy/core/src/multiarraymodule.c 2008-07-16 03:33:12 UTC (rev 5429) +++ trunk/numpy/core/src/multiarraymodule.c 2008-07-16 05:38:55 UTC (rev 5430) @@ -1685,7 +1685,11 @@ { intp newdims[2]; PyArray_Descr *descr; + char msg[] = "PyArray_As1D: use PyArray_AsCArray."; + if (DEPRECATE(msg) < 0) { + return -1; + } descr = PyArray_DescrFromType(typecode); if (PyArray_AsCArray(op, (void *)ptr, newdims, 2, descr) == -1) return -1; From numpy-svn at scipy.org Wed Jul 16 11:50:09 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 10:50:09 -0500 (CDT) Subject: [Numpy-svn] r5431 - branches/1.1.x/numpy/doc/cython Message-ID: <20080716155009.3E70339C3D8@scipy.org> Author: charris Date: 2008-07-16 10:49:59 -0500 (Wed, 16 Jul 2008) New Revision: 5431 Added: branches/1.1.x/numpy/doc/cython/c_numpy.pxd branches/1.1.x/numpy/doc/cython/c_python.pxd Removed: branches/1.1.x/numpy/doc/cython/Python.pxi branches/1.1.x/numpy/doc/cython/numpy.pxi Log: Backport first half r5298. Deleted: branches/1.1.x/numpy/doc/cython/Python.pxi =================================================================== --- branches/1.1.x/numpy/doc/cython/Python.pxi 2008-07-16 05:38:55 UTC (rev 5430) +++ branches/1.1.x/numpy/doc/cython/Python.pxi 2008-07-16 15:49:59 UTC (rev 5431) @@ -1,62 +0,0 @@ -# :Author: Robert Kern -# :Copyright: 2004, Enthought, Inc. -# :License: BSD Style - - -cdef extern from "Python.h": - # Not part of the Python API, but we might as well define it here. - # Note that the exact type doesn't actually matter for Pyrex. - ctypedef int size_t - - # Some type declarations we need - ctypedef int Py_intptr_t - - - # String API - char* PyString_AsString(object string) - char* PyString_AS_STRING(object string) - object PyString_FromString(char* c_string) - object PyString_FromStringAndSize(char* c_string, int length) - object PyString_InternFromString(char *v) - - # Float API - object PyFloat_FromDouble(double v) - double PyFloat_AsDouble(object ob) - long PyInt_AsLong(object ob) - - - # Memory API - void* PyMem_Malloc(size_t n) - void* PyMem_Realloc(void* buf, size_t n) - void PyMem_Free(void* buf) - - void Py_DECREF(object obj) - void Py_XDECREF(object obj) - void Py_INCREF(object obj) - void Py_XINCREF(object obj) - - # CObject API - ctypedef void (*destructor1)(void* cobj) - ctypedef void (*destructor2)(void* cobj, void* desc) - int PyCObject_Check(object p) - object PyCObject_FromVoidPtr(void* cobj, destructor1 destr) - object PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, - destructor2 destr) - void* PyCObject_AsVoidPtr(object self) - void* PyCObject_GetDesc(object self) - int PyCObject_SetVoidPtr(object self, void* cobj) - - # TypeCheck API - int PyFloat_Check(object obj) - int PyInt_Check(object obj) - - # Error API - int PyErr_Occurred() - void PyErr_Clear() - int PyErr_CheckSignals() - -cdef extern from "string.h": - void *memcpy(void *s1, void *s2, int n) - -cdef extern from "math.h": - double fabs(double x) Copied: branches/1.1.x/numpy/doc/cython/c_numpy.pxd (from rev 5429, branches/1.1.x/numpy/doc/cython/numpy.pxi) Copied: branches/1.1.x/numpy/doc/cython/c_python.pxd (from rev 5429, branches/1.1.x/numpy/doc/cython/Python.pxi) Deleted: branches/1.1.x/numpy/doc/cython/numpy.pxi =================================================================== --- branches/1.1.x/numpy/doc/cython/numpy.pxi 2008-07-16 05:38:55 UTC (rev 5430) +++ branches/1.1.x/numpy/doc/cython/numpy.pxi 2008-07-16 15:49:59 UTC (rev 5431) @@ -1,133 +0,0 @@ -# :Author: Travis Oliphant - -cdef extern from "numpy/arrayobject.h": - - cdef enum NPY_TYPES: - NPY_BOOL - NPY_BYTE - NPY_UBYTE - NPY_SHORT - NPY_USHORT - NPY_INT - NPY_UINT - NPY_LONG - NPY_ULONG - NPY_LONGLONG - NPY_ULONGLONG - NPY_FLOAT - NPY_DOUBLE - NPY_LONGDOUBLE - NPY_CFLOAT - NPY_CDOUBLE - NPY_CLONGDOUBLE - NPY_OBJECT - NPY_STRING - NPY_UNICODE - NPY_VOID - NPY_NTYPES - NPY_NOTYPE - - cdef enum requirements: - NPY_CONTIGUOUS - NPY_FORTRAN - NPY_OWNDATA - NPY_FORCECAST - NPY_ENSURECOPY - NPY_ENSUREARRAY - NPY_ELEMENTSTRIDES - NPY_ALIGNED - NPY_NOTSWAPPED - NPY_WRITEABLE - NPY_UPDATEIFCOPY - NPY_ARR_HAS_DESCR - - NPY_BEHAVED - NPY_BEHAVED_NS - NPY_CARRAY - NPY_CARRAY_RO - NPY_FARRAY - NPY_FARRAY_RO - NPY_DEFAULT - - NPY_IN_ARRAY - NPY_OUT_ARRAY - NPY_INOUT_ARRAY - NPY_IN_FARRAY - NPY_OUT_FARRAY - NPY_INOUT_FARRAY - - NPY_UPDATE_ALL - - cdef enum defines: - NPY_MAXDIMS - - ctypedef struct npy_cdouble: - double real - double imag - - ctypedef struct npy_cfloat: - double real - double imag - - ctypedef int npy_intp - - ctypedef extern class numpy.dtype [object PyArray_Descr]: - cdef int type_num, elsize, alignment - cdef char type, kind, byteorder, hasobject - cdef object fields, typeobj - - ctypedef extern class numpy.ndarray [object PyArrayObject]: - cdef char *data - cdef int nd - cdef npy_intp *dimensions - cdef npy_intp *strides - cdef object base - cdef dtype descr - cdef int flags - - ctypedef extern class numpy.flatiter [object PyArrayIterObject]: - cdef int nd_m1 - cdef npy_intp index, size - cdef ndarray ao - cdef char *dataptr - - ctypedef extern class numpy.broadcast [object PyArrayMultiIterObject]: - cdef int numiter - cdef npy_intp size, index - cdef int nd - cdef npy_intp *dimensions - cdef void **iters - - object PyArray_ZEROS(int ndims, npy_intp* dims, NPY_TYPES type_num, int fortran) - object PyArray_EMPTY(int ndims, npy_intp* dims, NPY_TYPES type_num, int fortran) - dtype PyArray_DescrFromTypeNum(NPY_TYPES type_num) - object PyArray_SimpleNew(int ndims, npy_intp* dims, NPY_TYPES type_num) - int PyArray_Check(object obj) - object PyArray_ContiguousFromAny(object obj, NPY_TYPES type, - int mindim, int maxdim) - object PyArray_ContiguousFromObject(object obj, NPY_TYPES type, - int mindim, int maxdim) - npy_intp PyArray_SIZE(ndarray arr) - npy_intp PyArray_NBYTES(ndarray arr) - void *PyArray_DATA(ndarray arr) - object PyArray_FromAny(object obj, dtype newtype, int mindim, int maxdim, - int requirements, object context) - object PyArray_FROMANY(object obj, NPY_TYPES type_num, int min, - int max, int requirements) - object PyArray_NewFromDescr(object subtype, dtype newtype, int nd, - npy_intp* dims, npy_intp* strides, void* data, - int flags, object parent) - - object PyArray_FROM_OTF(object obj, NPY_TYPES type, int flags) - object PyArray_EnsureArray(object) - - object PyArray_MultiIterNew(int n, ...) - - char *PyArray_MultiIter_DATA(broadcast multi, int i) - void PyArray_MultiIter_NEXTi(broadcast multi, int i) - void PyArray_MultiIter_NEXT(broadcast multi) - - object PyArray_IterNew(object arr) - void PyArray_ITER_NEXT(flatiter it) - - void import_array() From numpy-svn at scipy.org Wed Jul 16 11:53:39 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 10:53:39 -0500 (CDT) Subject: [Numpy-svn] r5432 - branches/1.1.x/numpy/doc/cython Message-ID: <20080716155339.CC47339C3D8@scipy.org> Author: charris Date: 2008-07-16 10:53:36 -0500 (Wed, 16 Jul 2008) New Revision: 5432 Modified: branches/1.1.x/numpy/doc/cython/Makefile branches/1.1.x/numpy/doc/cython/numpyx.pyx Log: Finish backport of r5298. Modified: branches/1.1.x/numpy/doc/cython/Makefile =================================================================== --- branches/1.1.x/numpy/doc/cython/Makefile 2008-07-16 15:49:59 UTC (rev 5431) +++ branches/1.1.x/numpy/doc/cython/Makefile 2008-07-16 15:53:36 UTC (rev 5432) @@ -24,7 +24,7 @@ numpyx.pyx.html: numpyx.pyx cython -a numpyx.pyx - @echo "Annotated HTML of the C code generated in numpy.pyx.html" + @echo "Annotated HTML of the C code generated in numpyx.html" # Phony targets for cleanup and similar uses Modified: branches/1.1.x/numpy/doc/cython/numpyx.pyx =================================================================== --- branches/1.1.x/numpy/doc/cython/numpyx.pyx 2008-07-16 15:49:59 UTC (rev 5431) +++ branches/1.1.x/numpy/doc/cython/numpyx.pyx 2008-07-16 15:53:36 UTC (rev 5432) @@ -2,21 +2,30 @@ """Cython access to Numpy arrays - simple example. """ -# Includes from the python headers -include "Python.pxi" -# Include the Numpy C API for use via Cython extension code -include "numpy.pxi" +############################################################################# +# Load C APIs declared in .pxd files via cimport +# +# A 'cimport' is similar to a Python 'import' statement, but it provides access +# to the C part of a library instead of its Python-visible API. See the +# Pyrex/Cython documentation for details. -################################################ -# Initialize numpy - this MUST be done before any other code is executed. -import_array() +cimport c_python as py -# Import the Numpy module for access to its usual Python API +cimport c_numpy as cnp + +# NOTE: numpy MUST be initialized before any other code is executed. +cnp.import_array() + +############################################################################# +# Load Python modules via normal import statements + import numpy as np +############################################################################# +# Regular code section begins # A 'def' function is visible in the Python-imported module -def print_array_info(ndarray arr): +def print_array_info(cnp.ndarray arr): """Simple information printer about an array. Code meant to illustrate Cython/NumPy integration only.""" @@ -24,19 +33,19 @@ cdef int i print '-='*10 - # Note: the double cast here (void * first, then Py_intptr_t) is needed in - # Cython but not in Pyrex, since the casting behavior of cython is slightly - # different (and generally safer) than that of Pyrex. In this case, we - # just want the memory address of the actual Array object, so we cast it to - # void before doing the Py_intptr_t cast: + # Note: the double cast here (void * first, then py.Py_intptr_t) is needed + # in Cython but not in Pyrex, since the casting behavior of cython is + # slightly different (and generally safer) than that of Pyrex. In this + # case, we just want the memory address of the actual Array object, so we + # cast it to void before doing the py.Py_intptr_t cast: print 'Printing array info for ndarray at 0x%0lx'% \ - (arr,) + (arr,) print 'number of dimensions:',arr.nd - print 'address of strides: 0x%0lx'%(arr.strides,) + print 'address of strides: 0x%0lx'%(arr.strides,) print 'strides:' for i from 0<=iarr.strides[i] + print ' stride %d:'%i,arr.strides[i] print 'memory dump:' print_elements( arr.data, arr.strides, arr.dimensions, arr.nd, sizeof(double), arr.dtype ) @@ -46,12 +55,12 @@ # A 'cdef' function is NOT visible to the python side, but it is accessible to # the rest of this Cython module cdef print_elements(char *data, - Py_intptr_t* strides, - Py_intptr_t* dimensions, + py.Py_intptr_t* strides, + py.Py_intptr_t* dimensions, int nd, int elsize, object dtype): - cdef Py_intptr_t i,j + cdef py.Py_intptr_t i,j cdef void* elptr if dtype not in [np.dtype(np.object_), @@ -78,7 +87,7 @@ print_elements(data, strides+1, dimensions+1, nd-1, elsize, dtype) data = data + strides[0] -def test_methods(ndarray arr): +def test_methods(cnp.ndarray arr): """Test a few attribute accesses for an array. This illustrates how the pyrex-visible object is in practice a strange From numpy-svn at scipy.org Wed Jul 16 11:59:06 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 10:59:06 -0500 (CDT) Subject: [Numpy-svn] r5433 - branches/1.1.x/numpy/doc/cython Message-ID: <20080716155906.77D3839C65E@scipy.org> Author: charris Date: 2008-07-16 10:59:03 -0500 (Wed, 16 Jul 2008) New Revision: 5433 Modified: branches/1.1.x/numpy/doc/cython/c_numpy.pxd Log: Finish sync of doc/cython/ to trunk. Modified: branches/1.1.x/numpy/doc/cython/c_numpy.pxd =================================================================== --- branches/1.1.x/numpy/doc/cython/c_numpy.pxd 2008-07-16 15:53:36 UTC (rev 5432) +++ branches/1.1.x/numpy/doc/cython/c_numpy.pxd 2008-07-16 15:59:03 UTC (rev 5433) @@ -1,5 +1,8 @@ # :Author: Travis Oliphant +# API declaration section. This basically exposes the NumPy C API to +# Pyrex/Cython programs. + cdef extern from "numpy/arrayobject.h": cdef enum NPY_TYPES: From numpy-svn at scipy.org Wed Jul 16 15:46:44 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 14:46:44 -0500 (CDT) Subject: [Numpy-svn] r5434 - trunk/numpy/core/src Message-ID: <20080716194644.A3B0039C3D8@scipy.org> Author: charris Date: 2008-07-16 14:46:41 -0500 (Wed, 16 Jul 2008) New Revision: 5434 Modified: trunk/numpy/core/src/multiarraymodule.c trunk/numpy/core/src/scalartypes.inc.src Log: Coding style cleanup. Replace hard tabs with spaces. Modified: trunk/numpy/core/src/multiarraymodule.c =================================================================== --- trunk/numpy/core/src/multiarraymodule.c 2008-07-16 15:59:03 UTC (rev 5433) +++ trunk/numpy/core/src/multiarraymodule.c 2008-07-16 19:46:41 UTC (rev 5434) @@ -2164,12 +2164,12 @@ if (from->f->cancastscalarkindto && (castlist = from->f->cancastscalarkindto[scalar])) { while (*castlist != PyArray_NOTYPE) - if (*castlist++ == neededtype) { - Py_DECREF(from); - return 1; - } + if (*castlist++ == neededtype) { + Py_DECREF(from); + return 1; + } } - Py_DECREF(from); + Py_DECREF(from); switch(scalar) { case PyArray_BOOL_SCALAR: Modified: trunk/numpy/core/src/scalartypes.inc.src =================================================================== --- trunk/numpy/core/src/scalartypes.inc.src 2008-07-16 15:59:03 UTC (rev 5433) +++ trunk/numpy/core/src/scalartypes.inc.src 2008-07-16 19:46:41 UTC (rev 5434) @@ -1895,24 +1895,25 @@ static PyObject * @name at _arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *obj=NULL; + PyObject *obj = NULL; PyObject *robj; PyObject *arr; - PyArray_Descr *typecode=NULL; + PyArray_Descr *typecode = NULL; int itemsize; void *dest, *src; _WORK at work@ - if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL; - + if (!PyArg_ParseTuple(args, "|O", &obj)) { + return NULL; + } typecode = PyArray_DescrFromType(PyArray_ at TYPE@); - /* typecode is new reference and stolen by + /* typecode is new reference and stolen by PyArray_Scalar and others */ if (obj == NULL) { #if @default@ == 0 - char *mem; - mem = malloc(sizeof(@name@)); + char *mem = malloc(sizeof(@name@)); + memset(mem, 0, sizeof(@name@)); robj = PyArray_Scalar(mem, typecode, NULL); free(mem); @@ -1926,20 +1927,30 @@ } arr = PyArray_FromAny(obj, typecode, 0, 0, FORCECAST, NULL); - if ((arr==NULL) || (PyArray_NDIM(arr) > 0)) return arr; + if ((arr == NULL) || (PyArray_NDIM(arr) > 0)) { + return arr; + } robj = PyArray_Return((PyArrayObject *)arr); finish: - if ((robj==NULL) || (robj->ob_type == type)) return robj; + if ((robj == NULL) || (robj->ob_type == type)) { + return robj; + } /* Need to allocate new type and copy data-area over */ if (type->tp_itemsize) { itemsize = PyString_GET_SIZE(robj); } - else itemsize = 0; + else { + itemsize = 0; + } obj = type->tp_alloc(type, itemsize); - if (obj == NULL) {Py_DECREF(robj); return NULL;} - if (typecode==NULL) + if (obj == NULL) { + Py_DECREF(robj); + return NULL; + } + if (typecode == NULL) { typecode = PyArray_DescrFromType(PyArray_ at TYPE@); + } dest = scalar_value(obj, typecode); src = scalar_value(robj, typecode); Py_DECREF(typecode); From numpy-svn at scipy.org Wed Jul 16 15:47:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 14:47:30 -0500 (CDT) Subject: [Numpy-svn] r5435 - branches/1.1.x/numpy/core/src Message-ID: <20080716194730.7819539C3D8@scipy.org> Author: charris Date: 2008-07-16 14:47:28 -0500 (Wed, 16 Jul 2008) New Revision: 5435 Modified: branches/1.1.x/numpy/core/src/multiarraymodule.c Log: Replace hard tabs with spaces. Modified: branches/1.1.x/numpy/core/src/multiarraymodule.c =================================================================== --- branches/1.1.x/numpy/core/src/multiarraymodule.c 2008-07-16 19:46:41 UTC (rev 5434) +++ branches/1.1.x/numpy/core/src/multiarraymodule.c 2008-07-16 19:47:28 UTC (rev 5435) @@ -2144,10 +2144,10 @@ if (from->f->cancastscalarkindto && (castlist = from->f->cancastscalarkindto[scalar])) { while (*castlist != PyArray_NOTYPE) - if (*castlist++ == neededtype) { - Py_DECREF(from); - return 1; - } + if (*castlist++ == neededtype) { + Py_DECREF(from); + return 1; + } } Py_DECREF(from); From numpy-svn at scipy.org Wed Jul 16 16:23:31 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 15:23:31 -0500 (CDT) Subject: [Numpy-svn] r5436 - trunk/numpy/core/src Message-ID: <20080716202331.8109939C50D@scipy.org> Author: charris Date: 2008-07-16 15:23:29 -0500 (Wed, 16 Jul 2008) New Revision: 5436 Modified: trunk/numpy/core/src/arrayobject.c Log: Fix ticket #850. Thanks to Michael Abbott for the patch. Modified: trunk/numpy/core/src/arrayobject.c =================================================================== --- trunk/numpy/core/src/arrayobject.c 2008-07-16 19:47:28 UTC (rev 5435) +++ trunk/numpy/core/src/arrayobject.c 2008-07-16 20:23:29 UTC (rev 5436) @@ -4717,24 +4717,24 @@ PyObject *new; if (self->descr->type_num == PyArray_STRING && \ other->descr->type_num == PyArray_UNICODE) { - Py_INCREF(other); Py_INCREF(other->descr); new = PyArray_FromAny((PyObject *)self, other->descr, 0, 0, 0, NULL); if (new == NULL) { return NULL; } + Py_INCREF(other); self = (PyArrayObject *)new; } else if (self->descr->type_num == PyArray_UNICODE && \ other->descr->type_num == PyArray_STRING) { - Py_INCREF(self); Py_INCREF(self->descr); new = PyArray_FromAny((PyObject *)other, self->descr, 0, 0, 0, NULL); if (new == NULL) { return NULL; } + Py_INCREF(self); other = (PyArrayObject *)new; } else { From numpy-svn at scipy.org Wed Jul 16 16:24:34 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 15:24:34 -0500 (CDT) Subject: [Numpy-svn] r5437 - branches/1.1.x/numpy/core/src Message-ID: <20080716202434.A604439C50D@scipy.org> Author: charris Date: 2008-07-16 15:24:32 -0500 (Wed, 16 Jul 2008) New Revision: 5437 Modified: branches/1.1.x/numpy/core/src/arrayobject.c Log: Backport fix for ticket #850. Modified: branches/1.1.x/numpy/core/src/arrayobject.c =================================================================== --- branches/1.1.x/numpy/core/src/arrayobject.c 2008-07-16 20:23:29 UTC (rev 5436) +++ branches/1.1.x/numpy/core/src/arrayobject.c 2008-07-16 20:24:32 UTC (rev 5437) @@ -4714,24 +4714,24 @@ PyObject *new; if (self->descr->type_num == PyArray_STRING && \ other->descr->type_num == PyArray_UNICODE) { - Py_INCREF(other); Py_INCREF(other->descr); new = PyArray_FromAny((PyObject *)self, other->descr, 0, 0, 0, NULL); if (new == NULL) { return NULL; } + Py_INCREF(other); self = (PyArrayObject *)new; } else if (self->descr->type_num == PyArray_UNICODE && \ other->descr->type_num == PyArray_STRING) { - Py_INCREF(self); Py_INCREF(self->descr); new = PyArray_FromAny((PyObject *)other, self->descr, 0, 0, 0, NULL); if (new == NULL) { return NULL; } + Py_INCREF(self); other = (PyArrayObject *)new; } else { From numpy-svn at scipy.org Wed Jul 16 17:01:44 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 16:01:44 -0500 (CDT) Subject: [Numpy-svn] r5438 - in trunk/numpy/core: src tests Message-ID: <20080716210144.0052439C137@scipy.org> Author: ptvirtan Date: 2008-07-16 16:01:31 -0500 (Wed, 16 Jul 2008) New Revision: 5438 Modified: trunk/numpy/core/src/multiarraymodule.c trunk/numpy/core/tests/test_multiarray.py Log: Fix ticket #837. Avoid infinite loop in fromfile/fromstring by ensuring that *_skip_separator always consumes at least one character or fails. Modified: trunk/numpy/core/src/multiarraymodule.c =================================================================== --- trunk/numpy/core/src/multiarraymodule.c 2008-07-16 20:24:32 UTC (rev 5437) +++ trunk/numpy/core/src/multiarraymodule.c 2008-07-16 21:01:31 UTC (rev 5438) @@ -6051,7 +6051,8 @@ /* Assuming that the separator is the next bit in the string (file), skip it. Single spaces in the separator are matched to arbitrary-long sequences - of whitespace in the input. + of whitespace in the input. If the separator consists only of spaces, + it matches one or more whitespace characters. If we can't match the separator, return -2. If we hit the end of the string (file), return -1. @@ -6069,10 +6070,17 @@ result = -1; break; } else if (*sep == '\0') { - /* matched separator */ - result = 0; - break; + if (string != *s) { + /* matched separator */ + result = 0; + break; + } else { + /* separator was whitespace wildcard that didn't match */ + result = -2; + break; + } } else if (*sep == ' ') { + /* whitespace wildcard */ if (!isspace(c)) { sep++; continue; @@ -6093,20 +6101,31 @@ fromfile_skip_separator(FILE **fp, const char *sep, void *stream_data) { int result = 0; + const char *sep_start = sep; while (1) { int c = fgetc(*fp); if (c == EOF) { result = -1; break; } else if (*sep == '\0') { - /* matched separator */ ungetc(c, *fp); - result = 0; - break; + if (sep != sep_start) { + /* matched separator */ + result = 0; + break; + } else { + /* separator was whitespace wildcard that didn't match */ + result = -2; + break; + } } else if (*sep == ' ') { + /* whitespace wildcard */ if (!isspace(c)) { sep++; + sep_start++; ungetc(c, *fp); + } else if (sep == sep_start) { + sep_start--; } } else if (*sep != c) { ungetc(c, *fp); Modified: trunk/numpy/core/tests/test_multiarray.py =================================================================== --- trunk/numpy/core/tests/test_multiarray.py 2008-07-16 20:24:32 UTC (rev 5437) +++ trunk/numpy/core/tests/test_multiarray.py 2008-07-16 21:01:31 UTC (rev 5438) @@ -143,7 +143,11 @@ assert_array_equal(a, [1.,2.,3.,4.]) assert_array_equal(a,b) + def test_malformed(self): + a = fromstring('1.234 1,234', sep=' ') + assert_array_equal(a, [1.234, 1.]) + class TestZeroRank(TestCase): def setUp(self): self.d = array(0), array('x', object) @@ -814,6 +818,13 @@ y = np.fromfile(filename,dtype=self.dtype) assert_array_equal(y,self.x.flat) + def test_malformed(self): + filename = tempfile.mktemp() + f = open(filename,'w') + f.write("1.234 1,234") + f.close() + y = np.fromfile(filename, sep=' ') + assert_array_equal(y, [1.234, 1.]) class TestFromBuffer(TestCase): def tst_basic(self,buffer,expected,kwargs): From numpy-svn at scipy.org Wed Jul 16 17:07:52 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 16:07:52 -0500 (CDT) Subject: [Numpy-svn] r5439 - trunk/numpy/core/blasdot Message-ID: <20080716210752.5B99739C65B@scipy.org> Author: charris Date: 2008-07-16 16:07:48 -0500 (Wed, 16 Jul 2008) New Revision: 5439 Modified: trunk/numpy/core/blasdot/_dotblas.c Log: Coding style cleanups. Modified: trunk/numpy/core/blasdot/_dotblas.c =================================================================== --- trunk/numpy/core/blasdot/_dotblas.c 2008-07-16 21:01:31 UTC (rev 5438) +++ trunk/numpy/core/blasdot/_dotblas.c 2008-07-16 21:07:48 UTC (rev 5439) @@ -177,7 +177,7 @@ /* This also makes sure that the data segment is aligned with - an itemsize address as well by returning one if not true. + an itemsize address as well by returning one if not true. */ static int _bad_strides(PyArrayObject *ap) @@ -189,14 +189,18 @@ if (((intp)(ap->data) % itemsize) != 0) return 1; for (i=0; ind > 2) || (ap2->nd > 2)) { - /* This function doesn't handle dimensions greater than 2 - (or negative striding) -- other - than to ensure the dot function is altered - */ + /* + * This function doesn't handle dimensions greater than 2 + * (or negative striding) -- other + * than to ensure the dot function is altered + */ if (!altered) { /* need to alter dot product */ PyObject *tmp1, *tmp2; @@ -265,13 +276,17 @@ op1 = PyArray_NewCopy(ap1, PyArray_ANYORDER); Py_DECREF(ap1); ap1 = (PyArrayObject *)op1; - if (ap1 == NULL) goto fail; + if (ap1 == NULL) { + goto fail; + } } if (_bad_strides(ap2)) { op2 = PyArray_NewCopy(ap2, PyArray_ANYORDER); Py_DECREF(ap2); ap2 = (PyArrayObject *)op2; - if (ap2 == NULL) goto fail; + if (ap2 == NULL) { + goto fail; + } } ap1shape = _select_matrix_shape(ap1); ap2shape = _select_matrix_shape(ap2); @@ -288,8 +303,12 @@ ap2shape = _scalar; } - if (ap1shape == _row) ap1stride = ap1->strides[1]; - else if (ap1->nd > 0) ap1stride = ap1->strides[0]; + if (ap1shape == _row) { + ap1stride = ap1->strides[1]; + } + else if (ap1->nd > 0) { + ap1stride = ap1->strides[0]; + } if (ap1->nd == 0 || ap2->nd == 0) { intp *thisdims; @@ -302,52 +321,64 @@ thisdims = ap1->dimensions; } l = 1; - for (j=0; jdimensions[oap1->nd-1]; + l = oap1->dimensions[oap1->nd - 1]; if (oap2->dimensions[0] != l) { PyErr_SetString(PyExc_ValueError, "matrices are not aligned"); goto fail; } nd = ap1->nd + ap2->nd - 2; - /* nd = 0 or 1 or 2 */ - /* If nd == 0 do nothing ... */ + /* + * nd = 0 or 1 or 2. If nd == 0 do nothing ... + */ if (nd == 1) { - /* Either ap1->nd is 1 dim or ap2->nd is 1 dim - and the other is 2-dim */ + /* + * Either ap1->nd is 1 dim or ap2->nd is 1 dim + * and the other is 2-dim + */ dimensions[0] = (oap1->nd == 2) ? oap1->dimensions[0] : oap2->dimensions[1]; l = dimensions[0]; - /* Fix it so that dot(shape=(N,1), shape=(1,)) - and dot(shape=(1,), shape=(1,N)) both return - an (N,) array (but use the fast scalar code) - */ + /* + * Fix it so that dot(shape=(N,1), shape=(1,)) + * and dot(shape=(1,), shape=(1,N)) both return + * an (N,) array (but use the fast scalar code) + */ } else if (nd == 2) { dimensions[0] = oap1->dimensions[0]; dimensions[1] = oap2->dimensions[1]; - /* We need to make sure that dot(shape=(1,1), shape=(1,N)) - and dot(shape=(N,1),shape=(1,1)) uses - scalar multiplication appropriately - */ - if (ap1shape == _row) l = dimensions[1]; - else l = dimensions[0]; + /* + * We need to make sure that dot(shape=(1,1), shape=(1,N)) + * and dot(shape=(N,1),shape=(1,1)) uses + * scalar multiplication appropriately + */ + if (ap1shape == _row) { + l = dimensions[1]; + } + else { + l = dimensions[0]; + } } } } - else { /* (ap1->nd <= 2 && ap2->nd <= 2) */ - /* Both ap1 and ap2 are vectors or matrices */ - l = ap1->dimensions[ap1->nd-1]; + else { + /* + * (ap1->nd <= 2 && ap2->nd <= 2) + * Both ap1 and ap2 are vectors or matrices + */ + l = ap1->dimensions[ap1->nd - 1]; if (ap2->dimensions[0] != l) { PyErr_SetString(PyExc_ValueError, "matrices are not aligned"); goto fail; } - nd = ap1->nd+ap2->nd-2; + nd = ap1->nd + ap2->nd - 2; if (nd == 1) dimensions[0] = (ap1->nd == 2) ? ap1->dimensions[0] : ap2->dimensions[1]; @@ -373,7 +404,9 @@ (PyObject *) (prior2 > prior1 ? ap2 : ap1)); - if (ret == NULL) goto fail; + if (ret == NULL) { + goto fail; + } numbytes = PyArray_NBYTES(ret); memset(ret->data, 0, numbytes); if (numbytes==0 || l == 0) { @@ -384,15 +417,16 @@ if (ap2shape == _scalar) { - /* Multiplication by a scalar -- Level 1 BLAS */ - /* if ap1shape is a matrix and we are not contiguous, then we can't - just blast through the entire array using a single - striding factor */ - NPY_BEGIN_ALLOW_THREADS + /* + * Multiplication by a scalar -- Level 1 BLAS + * if ap1shape is a matrix and we are not contiguous, then we can't + * just blast through the entire array using a single striding factor + */ + NPY_BEGIN_ALLOW_THREADS; if (typenum == PyArray_DOUBLE) { if (l == 1) { - *((double *)ret->data) = *((double *)ap2->data) * \ + *((double *)ret->data) = *((double *)ap2->data) * *((double *)ap1->data); } else if (ap1shape != _matrix) { @@ -403,6 +437,7 @@ int maxind, oind, i, a1s, rets; char *ptr, *rptr; double val; + maxind = (ap1->dimensions[0] >= ap1->dimensions[1] ? 0 : 1); oind = 1-maxind; ptr = ap1->data; @@ -411,7 +446,7 @@ val = *((double *)ap2->data); a1s = ap1->strides[maxind] / sizeof(double); rets = ret->strides[maxind] / sizeof(double); - for (i=0; i < ap1->dimensions[oind]; i++) { + for (i = 0; i < ap1->dimensions[oind]; i++) { cblas_daxpy(l, val, (double *)ptr, a1s, (double *)rptr, rets); ptr += ap1->strides[oind]; @@ -422,6 +457,7 @@ else if (typenum == PyArray_CDOUBLE) { if (l == 1) { cdouble *ptr1, *ptr2, *res; + ptr1 = (cdouble *)ap2->data; ptr2 = (cdouble *)ap1->data; res = (cdouble *)ret->data; @@ -436,6 +472,7 @@ int maxind, oind, i, a1s, rets; char *ptr, *rptr; double *pval; + maxind = (ap1->dimensions[0] >= ap1->dimensions[1] ? 0 : 1); oind = 1-maxind; ptr = ap1->data; @@ -444,7 +481,7 @@ pval = (double *)ap2->data; a1s = ap1->strides[maxind] / sizeof(cdouble); rets = ret->strides[maxind] / sizeof(cdouble); - for (i=0; i < ap1->dimensions[oind]; i++) { + for (i = 0; i < ap1->dimensions[oind]; i++) { cblas_zaxpy(l, pval, (double *)ptr, a1s, (double *)rptr, rets); ptr += ap1->strides[oind]; @@ -454,7 +491,7 @@ } else if (typenum == PyArray_FLOAT) { if (l == 1) { - *((float *)ret->data) = *((float *)ap2->data) * \ + *((float *)ret->data) = *((float *)ap2->data) * *((float *)ap1->data); } else if (ap1shape != _matrix) { @@ -465,6 +502,7 @@ int maxind, oind, i, a1s, rets; char *ptr, *rptr; float val; + maxind = (ap1->dimensions[0] >= ap1->dimensions[1] ? 0 : 1); oind = 1-maxind; ptr = ap1->data; @@ -473,7 +511,7 @@ val = *((float *)ap2->data); a1s = ap1->strides[maxind] / sizeof(float); rets = ret->strides[maxind] / sizeof(float); - for (i=0; i < ap1->dimensions[oind]; i++) { + for (i = 0; i < ap1->dimensions[oind]; i++) { cblas_saxpy(l, val, (float *)ptr, a1s, (float *)rptr, rets); ptr += ap1->strides[oind]; @@ -484,6 +522,7 @@ else if (typenum == PyArray_CFLOAT) { if (l == 1) { cfloat *ptr1, *ptr2, *res; + ptr1 = (cfloat *)ap2->data; ptr2 = (cfloat *)ap1->data; res = (cfloat *)ret->data; @@ -498,6 +537,7 @@ int maxind, oind, i, a1s, rets; char *ptr, *rptr; float *pval; + maxind = (ap1->dimensions[0] >= ap1->dimensions[1] ? 0 : 1); oind = 1-maxind; ptr = ap1->data; @@ -506,7 +546,7 @@ pval = (float *)ap2->data; a1s = ap1->strides[maxind] / sizeof(cfloat); rets = ret->strides[maxind] / sizeof(cfloat); - for (i=0; i < ap1->dimensions[oind]; i++) { + for (i = 0; i < ap1->dimensions[oind]; i++) { cblas_caxpy(l, pval, (float *)ptr, a1s, (float *)rptr, rets); ptr += ap1->strides[oind]; @@ -514,11 +554,11 @@ } } } - NPY_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS; } else if ((ap2shape == _column) && (ap1shape != _matrix)) { int ap1s, ap2s; - NPY_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS; ap2s = ap2->strides[0] / ap2->descr->elsize; if (ap1shape == _row) { @@ -547,7 +587,7 @@ cblas_cdotu_sub(l, (float *)ap1->data, ap1s, (float *)ap2->data, ap2s, (float *)ret->data); } - NPY_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS; } else if (ap1shape == _matrix && ap2shape != _matrix) { /* Matrix vector multiplication -- Level 2 BLAS */ @@ -560,7 +600,9 @@ new = PyArray_Copy(ap1); Py_DECREF(ap1); ap1 = (PyArrayObject *)new; - if (new == NULL) goto fail; + if (new == NULL) { + goto fail; + } } NPY_BEGIN_ALLOW_THREADS if (PyArray_ISCONTIGUOUS(ap1)) { @@ -598,7 +640,7 @@ (float *)ap2->data, ap2s, zeroF, (float *)ret->data, 1); } - NPY_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS; } else if (ap1shape != _matrix && ap2shape == _matrix) { /* Vector matrix multiplication -- Level 2 BLAS */ @@ -610,7 +652,9 @@ new = PyArray_Copy(ap2); Py_DECREF(ap2); ap2 = (PyArrayObject *)new; - if (new == NULL) goto fail; + if (new == NULL) { + goto fail; + } } NPY_BEGIN_ALLOW_THREADS if (PyArray_ISCONTIGUOUS(ap2)) { @@ -651,36 +695,44 @@ oneF, (float *)ap2->data, lda, (float *)ap1->data, ap1s, zeroF, (float *)ret->data, 1); } - NPY_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS; } - else { /* (ap1->nd == 2 && ap2->nd == 2) */ - /* Matrix matrix multiplication -- Level 3 BLAS */ - /* L x M multiplied by M x N */ + else { + /* + * (ap1->nd == 2 && ap2->nd == 2) + * Matrix matrix multiplication -- Level 3 BLAS + * L x M multiplied by M x N + */ enum CBLAS_ORDER Order; enum CBLAS_TRANSPOSE Trans1, Trans2; int M, N, L; /* Optimization possible: */ - /* We may be able to handle single-segment arrays here - using appropriate values of Order, Trans1, and Trans2. - */ + /* + * We may be able to handle single-segment arrays here + * using appropriate values of Order, Trans1, and Trans2. + */ if (!PyArray_ISCONTIGUOUS(ap2)) { - PyObject *new; - new = PyArray_Copy(ap2); + PyObject *new = PyArray_Copy(ap2); + Py_DECREF(ap2); ap2 = (PyArrayObject *)new; - if (new == NULL) goto fail; + if (new == NULL) { + goto fail; + } } if (!PyArray_ISCONTIGUOUS(ap1)) { - PyObject *new; - new = PyArray_Copy(ap1); + PyObject *new = PyArray_Copy(ap1); + Py_DECREF(ap1); ap1 = (PyArrayObject *)new; - if (new == NULL) goto fail; + if (new == NULL) { + goto fail; + } } - NPY_BEGIN_ALLOW_THREADS + NPY_BEGIN_ALLOW_THREADS; Order = CblasRowMajor; Trans1 = CblasNoTrans; @@ -719,7 +771,7 @@ (float *)ap2->data, ldb, zeroF, (float *)ret->data, ldc); } - NPY_END_ALLOW_THREADS + NPY_END_ALLOW_THREADS; } @@ -735,7 +787,11 @@ } -static char doc_innerproduct[] = "innerproduct(a,b)\nReturns the inner product of a and b for arrays of floating point types.\nLike the generic NumPy equivalent the product sum is over\nthe last dimension of a and b.\nNB: The first argument is not conjugated."; +static char doc_innerproduct[] = \ + "innerproduct(a,b)\nReturns the inner product of a and b for arrays of "\ + "floating point types.\nLike the generic NumPy equivalent the product "\ + "sum is over\nthe last dimension of a and b.\nNB: The first argument is "\ + "not conjugated."; static PyObject * dotblas_innerproduct(PyObject *dummy, PyObject *args) From numpy-svn at scipy.org Wed Jul 16 17:30:09 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 16:30:09 -0500 (CDT) Subject: [Numpy-svn] r5440 - trunk/numpy/core/blasdot Message-ID: <20080716213009.B525739C7D8@scipy.org> Author: charris Date: 2008-07-16 16:30:07 -0500 (Wed, 16 Jul 2008) New Revision: 5440 Modified: trunk/numpy/core/blasdot/_dotblas.c Log: Fix ticket #849. Thanks to Michael Abbott. The added check for NULL descr isn't really needed here because the typenums used don't allow such returns. But knowing that requires knowledge of PyArray_DescrFromType internals and not checking makes the code fragile. Modified: trunk/numpy/core/blasdot/_dotblas.c =================================================================== --- trunk/numpy/core/blasdot/_dotblas.c 2008-07-16 21:07:48 UTC (rev 5439) +++ trunk/numpy/core/blasdot/_dotblas.c 2008-07-16 21:30:07 UTC (rev 5440) @@ -206,10 +206,10 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args) { PyObject *op1, *op2; - PyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL; + PyArrayObject *ap1 = NULL, *ap2 = NULL, *ret = NULL; int j, l, lda, ldb, ldc; int typenum, nd; - intp ap1stride=0; + intp ap1stride = 0; intp dimensions[MAX_DIMS]; intp numbytes; static const float oneF[2] = {1.0, 0.0}; @@ -240,14 +240,19 @@ } dtype = PyArray_DescrFromType(typenum); + if (dtype == NULL) { + return NULL; + } + Py_INCREF(dtype); ap1 = (PyArrayObject *)PyArray_FromAny(op1, dtype, 0, 0, ALIGNED, NULL); if (ap1 == NULL) { + Py_DECREF(dtype); return NULL; } - Py_INCREF(dtype); ap2 = (PyArrayObject *)PyArray_FromAny(op2, dtype, 0, 0, ALIGNED, NULL); if (ap2 == NULL) { - goto fail; + Py_DECREF(ap1); + return NULL; } From numpy-svn at scipy.org Wed Jul 16 17:32:43 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 16:32:43 -0500 (CDT) Subject: [Numpy-svn] r5441 - trunk/numpy/core/blasdot Message-ID: <20080716213243.86AC739C862@scipy.org> Author: charris Date: 2008-07-16 16:32:41 -0500 (Wed, 16 Jul 2008) New Revision: 5441 Modified: trunk/numpy/core/blasdot/_dotblas.c Log: Remove blank line. Modified: trunk/numpy/core/blasdot/_dotblas.c =================================================================== --- trunk/numpy/core/blasdot/_dotblas.c 2008-07-16 21:30:07 UTC (rev 5440) +++ trunk/numpy/core/blasdot/_dotblas.c 2008-07-16 21:32:41 UTC (rev 5441) @@ -255,7 +255,6 @@ return NULL; } - if ((ap1->nd > 2) || (ap2->nd > 2)) { /* * This function doesn't handle dimensions greater than 2 From numpy-svn at scipy.org Wed Jul 16 17:34:01 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 16:34:01 -0500 (CDT) Subject: [Numpy-svn] r5442 - branches/1.1.x/numpy/core/blasdot Message-ID: <20080716213401.25C8B39C86A@scipy.org> Author: charris Date: 2008-07-16 16:33:55 -0500 (Wed, 16 Jul 2008) New Revision: 5442 Modified: branches/1.1.x/numpy/core/blasdot/_dotblas.c Log: Backport fix for ticket #849. Modified: branches/1.1.x/numpy/core/blasdot/_dotblas.c =================================================================== --- branches/1.1.x/numpy/core/blasdot/_dotblas.c 2008-07-16 21:32:41 UTC (rev 5441) +++ branches/1.1.x/numpy/core/blasdot/_dotblas.c 2008-07-16 21:33:55 UTC (rev 5442) @@ -234,13 +234,21 @@ } dtype = PyArray_DescrFromType(typenum); + if (dtype == NULL) { + return NULL; + } + Py_INCREF(dtype); ap1 = (PyArrayObject *)PyArray_FromAny(op1, dtype, 0, 0, ALIGNED, NULL); - if (ap1 == NULL) return NULL; - Py_INCREF(dtype); + if (ap1 == NULL) { + Py_DECREF(dtype); + return NULL; + } ap2 = (PyArrayObject *)PyArray_FromAny(op2, dtype, 0, 0, ALIGNED, NULL); - if (ap2 == NULL) goto fail; + if (ap2 == NULL) { + Py_DECREF(ap1); + return NULL; + } - if ((ap1->nd > 2) || (ap2->nd > 2)) { /* This function doesn't handle dimensions greater than 2 (or negative striding) -- other From numpy-svn at scipy.org Thu Jul 17 00:20:46 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 16 Jul 2008 23:20:46 -0500 (CDT) Subject: [Numpy-svn] r5443 - in trunk/numpy/ma: . tests Message-ID: <20080717042046.BC2E0C7C0D3@scipy.org> Author: pierregm Date: 2008-07-16 23:20:42 -0500 (Wed, 16 Jul 2008) New Revision: 5443 Modified: trunk/numpy/ma/core.py trunk/numpy/ma/mrecords.py trunk/numpy/ma/tests/test_core.py trunk/numpy/ma/tests/test_mrecords.py trunk/numpy/ma/testutils.py Log: testutils * improved check on object/record arrays core * fixed filled for flexible types * fixed the definition of the mask for flexible types mrecords: * fixed a bug w/ titles/formats in __new__ and __array_finalize__ Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-16 21:33:55 UTC (rev 5442) +++ trunk/numpy/ma/core.py 2008-07-17 04:20:42 UTC (rev 5443) @@ -38,7 +38,7 @@ 'isMA', 'isMaskedArray', 'is_mask', 'is_masked', 'isarray', 'left_shift', 'less', 'less_equal', 'load', 'loads', 'log', 'log10', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', - 'make_mask', 'make_mask_none', 'mask_or', 'masked', + 'make_mask', 'make_mask_descr', 'make_mask_none', 'mask_or', 'masked', 'masked_array', 'masked_equal', 'masked_greater', 'masked_greater_equal', 'masked_inside', 'masked_invalid', 'masked_less','masked_less_equal', 'masked_not_equal', @@ -125,7 +125,10 @@ if hasattr(obj,'dtype'): defval = default_filler[obj.dtype.kind] elif isinstance(obj, np.dtype): - defval = default_filler[obj.kind] + if obj.subdtype: + defval = default_filler[obj.subdtype[0].kind] + else: + defval = default_filler[obj.kind] elif isinstance(obj, float): defval = default_filler['f'] elif isinstance(obj, int) or isinstance(obj, long): @@ -185,26 +188,28 @@ def _check_fill_value(fill_value, ndtype): ndtype = np.dtype(ndtype) - nbfields = len(ndtype) + fields = ndtype.fields if fill_value is None: - if nbfields >= 1: - fill_value = np.array(tuple([default_fill_value(np.dtype(d)) - for (_, d) in ndtype.descr]), - dtype=ndtype) + if fields: + fdtype = [(_[0], _[1]) for _ in ndtype.descr] + fill_value = np.array(tuple([default_fill_value(fields[n][0]) + for n in ndtype.names]), + dtype=fdtype) else: fill_value = default_fill_value(ndtype) - elif nbfields >= 1: + elif fields: + fdtype = [(_[0], _[1]) for _ in ndtype.descr] if isinstance(fill_value, ndarray): try: - fill_value = np.array(fill_value, copy=False, dtype=ndtype) + fill_value = np.array(fill_value, copy=False, dtype=fdtype) except ValueError: err_msg = "Unable to transform %s to dtype %s" - raise ValueError(err_msg % (fill_value,ndtype)) + raise ValueError(err_msg % (fill_value,fdtype)) else: - fval = np.resize(fill_value, nbfields) - fill_value = tuple([np.asarray(f).astype(d).item() - for (f, (_, d)) in zip(fval, ndtype.descr)]) - fill_value = np.array(fill_value, copy=False, dtype=ndtype) + fval = np.resize(fill_value, len(ndtype.descr)) + fill_value = [np.asarray(f).astype(desc[1]).item() + for (f, desc) in zip(fval, ndtype.descr)] + fill_value = np.array(tuple(fill_value), copy=False, dtype=fdtype) else: if isinstance(fill_value, basestring) and (ndtype.char not in 'SV'): fill_value = default_fill_value(ndtype) @@ -726,6 +731,20 @@ #####-------------------------------------------------------------------------- #---- --- Mask creation functions --- #####-------------------------------------------------------------------------- + +def make_mask_descr(ndtype): + """Constructs a dtype description list from a given dtype. + Each field is set to a bool. + + """ + if ndtype.names: + mdescr = [list(_) for _ in ndtype.descr] + for m in mdescr: + m[1] = '|b1' + return [tuple(_) for _ in mdescr] + else: + return MaskType + def get_mask(a): """Return the mask of a, if any, or nomask. @@ -796,21 +815,21 @@ else: return result -def make_mask_none(newshape, fields=None): +def make_mask_none(newshape, dtype=None): """Return a mask of shape s, filled with False. Parameters ---------- news : tuple A tuple indicating the shape of the final mask. - fields: {None, string sequence}, optional - A list of field names, if needed. + dtype: {None, dtype}, optional + A dtype. """ - if not fields: + if dtype is None: result = np.zeros(newshape, dtype=MaskType) else: - result = np.zeros(newshape, dtype=[(n, MaskType) for n in fields]) + result = np.zeros(newshape, dtype=make_mask_descr(dtype)) return result def mask_or (m1, m2, copy=False, shrink=True): @@ -1219,7 +1238,7 @@ names_ = _data.dtype.names or () # Type of the mask if names_: - mdtype = [(n, MaskType) for n in names_] + mdtype = make_mask_descr(_data.dtype) else: mdtype = MaskType # Case 1. : no mask in input ............ @@ -1441,17 +1460,18 @@ return #........................................ # ndgetattr = ndarray.__getattribute__ - _names = ndarray.__getattribute__(self,'dtype').names or () _data = self._data + _dtype = ndarray.__getattribute__(_data,'dtype') _mask = ndarray.__getattribute__(self,'_mask') + nbfields = len(_dtype.names or ()) #........................................ if value is masked: # The mask wasn't set: create a full version... if _mask is nomask: - _mask = self._mask = make_mask_none(self.shape, _names) + _mask = self._mask = make_mask_none(self.shape, _dtype) # Now, set the mask to its value. - if _names: - _mask[indx] = tuple([True,] * len(_names)) + if nbfields: + _mask[indx] = tuple([True,] * nbfields) else: _mask[indx] = True if not self._isfield: @@ -1462,13 +1482,13 @@ dval = value # Get the _mask part of the new value mval = getattr(value, '_mask', nomask) - if _names and mval is nomask: - mval = tuple([False] * len(_names)) + if nbfields and mval is nomask: + mval = tuple([False] * nbfields) if _mask is nomask: # Set the data, then the mask ndarray.__setitem__(_data, indx, dval) if mval is not nomask: - _mask = self._mask = make_mask_none(self.shape, _names) + _mask = self._mask = make_mask_none(self.shape, _dtype) ndarray.__setitem__(_mask, indx, mval) elif not self._hardmask: # Unshare the mask if necessary to avoid propagation @@ -1482,7 +1502,7 @@ indx = indx * umath.logical_not(_mask) ndarray.__setitem__(_data,indx,dval) else: - if _names: + if nbfields: err_msg = "Flexible 'hard' masks are not yet supported..." raise NotImplementedError(err_msg) mindx = mask_or(_mask[indx], mval, copy=True) @@ -1517,7 +1537,7 @@ """Set the mask. """ - names = ndarray.__getattribute__(self,'dtype').names + idtype = ndarray.__getattribute__(self,'dtype') current_mask = ndarray.__getattribute__(self,'_mask') if mask is masked: mask = True @@ -1526,9 +1546,9 @@ # Just don't do anything is there's nothing to do... if mask is nomask: return - current_mask = self._mask = make_mask_none(self.shape, names) + current_mask = self._mask = make_mask_none(self.shape, idtype) # No named fields......... - if names is None: + if idtype.names is None: # Hardmask: don't unmask the data if self._hardmask: current_mask |= mask @@ -1559,7 +1579,7 @@ dtype=mdtype) # Hardmask: don't unmask the data if self._hardmask: - for n in names: + for n in idtype.names: current_mask[n] |= mask[n] # Softmask: set everything to False else: @@ -1584,13 +1604,20 @@ A record is masked when all the fields are masked. """ - if self.dtype.names is None: - return self._mask - elif self.size > 1: - return self._mask.view((bool_, len(self.dtype))).all(1) + _mask = ndarray.__getattribute__(self, '_mask').view(ndarray) + if _mask.dtype.names is None: + return _mask + if _mask.size > 1: + axis = 1 else: - return self._mask.view((bool_, len(self.dtype))).all() - + axis=None + # + try: + return _mask.view((bool_, len(self.dtype))).all(axis) + except ValueError: + return np.all([[f[n].all() for n in _mask.dtype.names] + for f in _mask], axis=axis) + def _setrecordmask(self): """Return the mask of the records. A record is masked when all the fields are masked. @@ -1707,15 +1734,17 @@ # if fill_value is None: fill_value = self.fill_value + else: + fill_value = _check_fill_value(fill_value, self.dtype) # if self is masked_singleton: return np.asanyarray(fill_value) # - if len(self.dtype): + if m.dtype.names: result = self._data.copy() for n in result.dtype.names: field = result[n] - np.putmask(field, self._mask[n], self.fill_value[n]) + np.putmask(field, self._mask[n], fill_value[n]) elif not m.any(): return self._data else: @@ -3515,7 +3544,7 @@ if getmask(a) is nomask: if valmask is not nomask: a._sharedmask = True - a._mask = make_mask_none(a.shape, a.dtype.names) + a._mask = make_mask_none(a.shape, a.dtype) np.putmask(a._mask, mask, valmask) elif a._hardmask: if valmask is not nomask: @@ -3899,3 +3928,5 @@ zeros = _convert2ma('zeros') ############################################################################### + + Modified: trunk/numpy/ma/mrecords.py =================================================================== --- trunk/numpy/ma/mrecords.py 2008-07-16 21:33:55 UTC (rev 5442) +++ trunk/numpy/ma/mrecords.py 2008-07-17 04:20:42 UTC (rev 5443) @@ -119,10 +119,11 @@ **options): # self = recarray.__new__(cls, shape, dtype=dtype, buf=buf, offset=offset, - strides=strides, formats=formats, - byteorder=byteorder, aligned=aligned,) + strides=strides, formats=formats, names=names, + titles=titles, byteorder=byteorder, + aligned=aligned,) # - mdtype = [(k,'|b1') for (k,_) in self.dtype.descr] + mdtype = ma.make_mask_descr(self.dtype) if mask is nomask or not np.size(mask): if not keep_mask: self._mask = tuple([False]*len(mdtype)) @@ -156,12 +157,11 @@ # Make sure we have a _fieldmask by default .. _fieldmask = getattr(obj, '_fieldmask', None) if _fieldmask is None: - mdescr = [(n,'|b1') for (n,_) in self.dtype.descr] objmask = getattr(obj, '_mask', nomask) if objmask is nomask: - _mask = np.empty(self.shape, dtype=mdescr).view(recarray) - _mask.flat = tuple([False]*len(mdescr)) + _mask = ma.make_mask_none(self.shape, dtype=self.dtype) else: + mdescr = ma.make_mask_descr(self.dtype) _mask = narray([tuple([m]*len(mdescr)) for m in objmask], dtype=mdescr).view(recarray) else: Modified: trunk/numpy/ma/tests/test_core.py =================================================================== --- trunk/numpy/ma/tests/test_core.py 2008-07-16 21:33:55 UTC (rev 5442) +++ trunk/numpy/ma/tests/test_core.py 2008-07-17 04:20:42 UTC (rev 5443) @@ -141,7 +141,7 @@ def test_creation_maskcreation(self): "Tests how masks are initialized at the creation of Maskedarrays." - data = arange(24, dtype=float_) + data = arange(24, dtype=float) data[[3,6,15]] = masked dma_1 = MaskedArray(data) assert_equal(dma_1.mask, data.mask) @@ -422,8 +422,20 @@ idx = atest.mask atest[idx] = btest[idx] assert_equal(atest,[20]) - #........................ + + def test_filled_w_flexible_dtype(self): + "Test filled w/ flexible dtype" + flexi = array([(1,1,1)], dtype=[('i',int), ('s','|S3'), ('f',float)]) + flexi[0] = masked + assert_equal(flexi.filled(), + np.array([(default_fill_value(0), + default_fill_value('0'), + default_fill_value(0.),)], dtype=flexi.dtype)) + flexi[0] = masked + assert_equal(flexi.filled(1), + np.array([(1, '1', 1.)], dtype=flexi.dtype)) + #------------------------------------------------------------------------------ class TestMaskedArrayArithmetic(TestCase): @@ -845,12 +857,12 @@ assert_equal(fval.item(), [default_fill_value(0), default_fill_value(0.), default_fill_value("0")]) - #.....Using a flexi-ndarray as fill_value should work + #.....Using a flexible type as fill_value should work fill_val = np.array((-999,-999.9,"???"),dtype=ndtype) fval = _check_fill_value(fill_val, ndtype) assert(isinstance(fval,ndarray)) assert_equal(fval.item(), [-999,-999.9,"???"]) - #.....Using a flexi-ndarray w/ a different type shouldn't matter + #.....Using a flexible type w/ a different type shouldn't matter fill_val = np.array((-999,-999.9,"???"), dtype=[("A",int),("B",float),("C","|S3")]) fval = _check_fill_value(fill_val, ndtype) @@ -866,7 +878,7 @@ fval = _check_fill_value(fill_val, ndtype) assert(isinstance(fval,ndarray)) assert_equal(fval.item(), [-999,-999.9,"???"]) - #.....One-field-only flexi-ndarray should work as well + #.....One-field-only flexible type should work as well ndtype = [("a",int)] fval = _check_fill_value(-999, ndtype) assert(isinstance(fval,ndarray)) @@ -904,7 +916,7 @@ series = data[[0,2,1]] assert_equal(series._fill_value, data._fill_value) # - mtype = [('f',float_),('s','|S3')] + mtype = [('f',float),('s','|S3')] x = array([(1,'a'),(2,'b'),(pi,'pi')], dtype=mtype) x.fill_value=999 assert_equal(x.fill_value.item(),[999.,'999']) @@ -918,10 +930,37 @@ # x = array([1,2,3.1]) x.fill_value = 999 - assert_equal(np.asarray(x.fill_value).dtype, float_) + assert_equal(np.asarray(x.fill_value).dtype, float) assert_equal(x.fill_value, 999.) + def test_fillvalue_exotic_dtype(self): + "Tests yet more exotic flexible dtypes" + _check_fill_value = np.ma.core._check_fill_value + ndtype = [('i',int), ('s','|S3'), ('f',float)] + control = np.array((default_fill_value(0), + default_fill_value('0'), + default_fill_value(0.),), + dtype=ndtype) + assert_equal(_check_fill_value(None, ndtype), control) + # The shape shouldn't matter + ndtype = [('f0', float, (2, 2))] + control = np.array((default_fill_value(0.),), + dtype=[('f0',float)]) + assert_equal(_check_fill_value(None, ndtype), control) + control = np.array((0,), dtype=[('f0',float)]) + assert_equal(_check_fill_value(0, ndtype), control) + # + ndtype = np.dtype("int, (2,3)float, float") + control = np.array((default_fill_value(0), + default_fill_value(0.), + default_fill_value(0.),), + dtype="int, float, float") + test = _check_fill_value(None, ndtype) + assert_equal(test, control) + control = np.array((0,0,0), dtype="int, float, float") + assert_equal(_check_fill_value(0, ndtype), control) + #------------------------------------------------------------------------------ class TestUfuncs(TestCase): @@ -1038,7 +1077,7 @@ """Test of inplace subtractions""" (x, y, xm) = self.floatdata m = xm.mask - a = arange(10, dtype=float_) + a = arange(10, dtype=float) a[-1] = masked x -= a xm -= a @@ -1058,7 +1097,7 @@ """Test of inplace multiplication""" (x, y, xm) = self.floatdata m = xm.mask - a = arange(10, dtype=float_) + a = arange(10, dtype=float) a[-1] = masked x *= a xm *= a @@ -1089,7 +1128,7 @@ """Test of inplace division""" (x, y, xm) = self.floatdata m = xm.mask - a = arange(10, dtype=float_) + a = arange(10, dtype=float) a[-1] = masked x /= a xm /= a @@ -1341,7 +1380,7 @@ def test_empty(self): "Tests empty/like" - datatype = [('a',int_),('b',float_),('c','|S8')] + datatype = [('a',int_),('b',float),('c','|S8')] a = masked_array([(1,1.1,'1.1'),(2,2.2,'2.2'),(3,3.3,'3.3')], dtype=datatype) assert_equal(len(a.fill_value.item()), len(datatype)) @@ -1606,7 +1645,7 @@ x = array(zip([1,2,3], [1.1,2.2,3.3], ['one','two','thr']), - dtype=[('a',int_),('b',float_),('c','|S8')]) + dtype=[('a',int_),('b',float),('c','|S8')]) x[-1] = masked assert_equal(x.tolist(), [(1,1.1,'one'),(2,2.2,'two'),(None,None,None)]) @@ -1690,8 +1729,8 @@ (x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d (n,m) = X.shape assert_equal(mx.ptp(),mx.compressed().ptp()) - rows = np.zeros(n,np.float_) - cols = np.zeros(m,np.float_) + rows = np.zeros(n,np.float) + cols = np.zeros(m,np.float) for k in range(m): cols[k] = mX[:,k].compressed().ptp() for k in range(n): @@ -1857,7 +1896,7 @@ def test_masked_where_oddities(self): """Tests some generic features.""" - atest = ones((10,10,10), dtype=float_) + atest = ones((10,10,10), dtype=float) btest = zeros(atest.shape, MaskType) ctest = masked_where(btest,atest) assert_equal(atest,ctest) Modified: trunk/numpy/ma/tests/test_mrecords.py =================================================================== --- trunk/numpy/ma/tests/test_mrecords.py 2008-07-16 21:33:55 UTC (rev 5442) +++ trunk/numpy/ma/tests/test_mrecords.py 2008-07-17 04:20:42 UTC (rev 5443) @@ -276,7 +276,7 @@ mbase._mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, - ma.make_mask_none(base.shape,base.dtype.names)) + ma.make_mask_none(base.shape,base.dtype)) assert(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask,mbase['b']._mask) # @@ -317,6 +317,33 @@ assert_equal(mrec.tolist(), [(1,1.1,None),(2,2.2,'two'),(None,None,'three')]) + + # + def test_withnames(self): + "Test the creation w/ format and names" + x = mrecarray(1, formats=float, names='base') + x[0]['base'] = 10 + assert_equal(x['base'][0], 10) + # + def test_exotic_formats(self): + "Test that 'exotic' formats are processed properly" + easy = mrecarray(1, dtype=[('i',int), ('s','|S3'), ('f',float)]) + easy[0] = masked + assert_equal(easy.filled(1).item(), (1,'1',1.)) + # + solo = mrecarray(1, dtype=[('f0', ' Author: ptvirtan Date: 2008-07-17 03:12:28 -0500 (Thu, 17 Jul 2008) New Revision: 5444 Modified: branches/1.1.x/numpy/core/src/multiarraymodule.c branches/1.1.x/numpy/core/tests/test_multiarray.py Log: Backport r5438 to 1.1.x. Fixes #837. Modified: branches/1.1.x/numpy/core/src/multiarraymodule.c =================================================================== --- branches/1.1.x/numpy/core/src/multiarraymodule.c 2008-07-17 04:20:42 UTC (rev 5443) +++ branches/1.1.x/numpy/core/src/multiarraymodule.c 2008-07-17 08:12:28 UTC (rev 5444) @@ -6040,7 +6040,8 @@ /* Assuming that the separator is the next bit in the string (file), skip it. Single spaces in the separator are matched to arbitrary-long sequences - of whitespace in the input. + of whitespace in the input. If the separator consists only of spaces, + it matches one or more whitespace characters. If we can't match the separator, return -2. If we hit the end of the string (file), return -1. @@ -6058,10 +6059,17 @@ result = -1; break; } else if (*sep == '\0') { - /* matched separator */ - result = 0; - break; + if (string != *s) { + /* matched separator */ + result = 0; + break; + } else { + /* separator was whitespace wildcard that didn't match */ + result = -2; + break; + } } else if (*sep == ' ') { + /* whitespace wildcard */ if (!isspace(c)) { sep++; continue; @@ -6082,20 +6090,31 @@ fromfile_skip_separator(FILE **fp, const char *sep, void *stream_data) { int result = 0; + const char *sep_start = sep; while (1) { int c = fgetc(*fp); if (c == EOF) { result = -1; break; } else if (*sep == '\0') { - /* matched separator */ ungetc(c, *fp); - result = 0; - break; + if (sep != sep_start) { + /* matched separator */ + result = 0; + break; + } else { + /* separator was whitespace wildcard that didn't match */ + result = -2; + break; + } } else if (*sep == ' ') { + /* whitespace wildcard */ if (!isspace(c)) { sep++; + sep_start++; ungetc(c, *fp); + } else if (sep == sep_start) { + sep_start--; } } else if (*sep != c) { ungetc(c, *fp); Modified: branches/1.1.x/numpy/core/tests/test_multiarray.py =================================================================== --- branches/1.1.x/numpy/core/tests/test_multiarray.py 2008-07-17 04:20:42 UTC (rev 5443) +++ branches/1.1.x/numpy/core/tests/test_multiarray.py 2008-07-17 08:12:28 UTC (rev 5444) @@ -142,6 +142,10 @@ assert_array_equal(a, [1.,2.,3.,4.]) assert_array_equal(a,b) + def test_malformed(self): + a = fromstring('1.234 1,234', sep=' ') + assert_array_equal(a, [1.234, 1.]) + class TestZeroRank(NumpyTestCase): def setUp(self): self.d = array(0), array('x', object) @@ -801,6 +805,14 @@ y = np.fromfile(filename,dtype=self.dtype) assert_array_equal(y,self.x.flat) + def test_malformed(self): + filename = tempfile.mktemp() + f = open(filename,'w') + f.write("1.234 1,234") + f.close() + y = np.fromfile(filename, sep=' ') + assert_array_equal(y, [1.234, 1.]) + class TestFromBuffer(ParametricTestCase): def tst_basic(self,buffer,expected,kwargs): assert_array_equal(np.frombuffer(buffer,**kwargs),expected) From numpy-svn at scipy.org Thu Jul 17 04:56:14 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 17 Jul 2008 03:56:14 -0500 (CDT) Subject: [Numpy-svn] r5445 - trunk/numpy/ma/tests Message-ID: <20080717085614.C19A639C13A@scipy.org> Author: rkern Date: 2008-07-17 03:56:08 -0500 (Thu, 17 Jul 2008) New Revision: 5445 Modified: trunk/numpy/ma/tests/test_core.py Log: FOR BUILDBOT: Change the test to make sure the double is aligned to a reasonable boundary. It does no harm to the test, but it shouldn't be necessary. However, I need the buildbots to test it out on the Sparc64 platform for me. Modified: trunk/numpy/ma/tests/test_core.py =================================================================== --- trunk/numpy/ma/tests/test_core.py 2008-07-17 08:12:28 UTC (rev 5444) +++ trunk/numpy/ma/tests/test_core.py 2008-07-17 08:56:08 UTC (rev 5445) @@ -426,7 +426,7 @@ def test_filled_w_flexible_dtype(self): "Test filled w/ flexible dtype" - flexi = array([(1,1,1)], dtype=[('i',int), ('s','|S3'), ('f',float)]) + flexi = array([(1,1,1)], dtype=[('i',int), ('s','|S8'), ('f',float)]) flexi[0] = masked assert_equal(flexi.filled(), np.array([(default_fill_value(0), From numpy-svn at scipy.org Thu Jul 17 05:09:09 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 17 Jul 2008 04:09:09 -0500 (CDT) Subject: [Numpy-svn] r5446 - trunk/numpy/ma/tests Message-ID: <20080717090909.3C3BD39C185@scipy.org> Author: rkern Date: 2008-07-17 04:09:04 -0500 (Thu, 17 Jul 2008) New Revision: 5446 Modified: trunk/numpy/ma/tests/test_core.py trunk/numpy/ma/tests/test_mrecords.py Log: FOR BUILDBOT: More unsavory workarounds for Sparc64. Change back when we've fixed the actual bug. Modified: trunk/numpy/ma/tests/test_core.py =================================================================== --- trunk/numpy/ma/tests/test_core.py 2008-07-17 08:56:08 UTC (rev 5445) +++ trunk/numpy/ma/tests/test_core.py 2008-07-17 09:09:04 UTC (rev 5446) @@ -937,7 +937,7 @@ def test_fillvalue_exotic_dtype(self): "Tests yet more exotic flexible dtypes" _check_fill_value = np.ma.core._check_fill_value - ndtype = [('i',int), ('s','|S3'), ('f',float)] + ndtype = [('i',int), ('s','|S8'), ('f',float)] control = np.array((default_fill_value(0), default_fill_value('0'), default_fill_value(0.),), Modified: trunk/numpy/ma/tests/test_mrecords.py =================================================================== --- trunk/numpy/ma/tests/test_mrecords.py 2008-07-17 08:56:08 UTC (rev 5445) +++ trunk/numpy/ma/tests/test_mrecords.py 2008-07-17 09:09:04 UTC (rev 5446) @@ -327,7 +327,7 @@ # def test_exotic_formats(self): "Test that 'exotic' formats are processed properly" - easy = mrecarray(1, dtype=[('i',int), ('s','|S3'), ('f',float)]) + easy = mrecarray(1, dtype=[('i',int), ('s','|S8'), ('f',float)]) easy[0] = masked assert_equal(easy.filled(1).item(), (1,'1',1.)) # From numpy-svn at scipy.org Thu Jul 17 09:18:04 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 17 Jul 2008 08:18:04 -0500 (CDT) Subject: [Numpy-svn] r5447 - trunk/numpy/doc/reference Message-ID: <20080717131804.98BA539C6FC@scipy.org> Author: stefan Date: 2008-07-17 08:17:45 -0500 (Thu, 17 Jul 2008) New Revision: 5447 Added: trunk/numpy/doc/reference/jargon.py Log: Add numpy.doc.jargon entry. Added: trunk/numpy/doc/reference/jargon.py =================================================================== --- trunk/numpy/doc/reference/jargon.py 2008-07-17 09:09:04 UTC (rev 5446) +++ trunk/numpy/doc/reference/jargon.py 2008-07-17 13:17:45 UTC (rev 5447) @@ -0,0 +1,9 @@ +""" + +====== +Jargon +====== + +Placeholder for computer science, engineering and other jargon. + +""" From numpy-svn at scipy.org Thu Jul 17 20:45:32 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 17 Jul 2008 19:45:32 -0500 (CDT) Subject: [Numpy-svn] r5448 - trunk/numpy/ma Message-ID: <20080718004532.6BB51C7C08F@scipy.org> Author: pierregm Date: 2008-07-17 19:45:23 -0500 (Thu, 17 Jul 2008) New Revision: 5448 Modified: trunk/numpy/ma/core.py Log: * fixed a pb with printing flexible ndarrays with subdtypes Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-17 13:17:45 UTC (rev 5447) +++ trunk/numpy/ma/core.py 2008-07-18 00:45:23 UTC (rev 5448) @@ -1824,7 +1824,11 @@ res = self._data.astype("|O8") res[m] = f else: - res = self._data.astype([(n,'|O8') for n in names]) + rdtype = [list(_) for _ in self.dtype.descr] + for r in rdtype: + r[1] = '|O8' + rdtype = [tuple(_) for _ in rdtype] + res = self._data.astype(rdtype) for field in names: np.putmask(res[field], m[field], f) else: From numpy-svn at scipy.org Thu Jul 17 22:02:23 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 17 Jul 2008 21:02:23 -0500 (CDT) Subject: [Numpy-svn] r5449 - in trunk/numpy/ma: . tests Message-ID: <20080718020223.DF10539C27D@scipy.org> Author: pierregm Date: 2008-07-17 21:02:19 -0500 (Thu, 17 Jul 2008) New Revision: 5449 Modified: trunk/numpy/ma/core.py trunk/numpy/ma/tests/test_core.py Log: * added .torecords(), to convert a masked array to a flexible array with fields '_data' and '_mask' Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-18 00:45:23 UTC (rev 5448) +++ trunk/numpy/ma/core.py 2008-07-18 02:02:19 UTC (rev 5449) @@ -3087,6 +3087,31 @@ def tofile(self, fid, sep="", format="%s"): raise NotImplementedError("Not implemented yet, sorry...") + def torecords(self): + """Transforms a masked array into a flexible-type array with two fields: + * the ``_data`` field stores the ``_data`` part of the array; + * the ``_mask`` field stores the ``_mask`` part of the array; + + Warnings + -------- + A side-effect of transforming a masked array into a flexible ndarray is + that metainformation (``fill_value``, ...) will be lost. + + """ + # Get the basic dtype .... + ddtype = self.dtype + # Make sure we have a mask + _mask = self._mask + if _mask is None: + _mask = make_mask_none(self.shape, ddtype) + # And get its dtype + mdtype = self._mask.dtype + # + record = np.ndarray(shape=self.shape, + dtype=[('_data',ddtype),('_mask',mdtype)]) + record['_data'] = self._data + record['_mask'] = self._mask + return record #-------------------------------------------- # Pickling def __getstate__(self): Modified: trunk/numpy/ma/tests/test_core.py =================================================================== --- trunk/numpy/ma/tests/test_core.py 2008-07-18 00:45:23 UTC (rev 5448) +++ trunk/numpy/ma/tests/test_core.py 2008-07-18 02:02:19 UTC (rev 5449) @@ -1650,6 +1650,38 @@ assert_equal(x.tolist(), [(1,1.1,'one'),(2,2.2,'two'),(None,None,None)]) + def test_torecords(self): + "Test the conversion to records" + data = arange(10) + record = data.torecords() + assert_equal(record['_data'], data._data) + assert_equal(record['_mask'], data._mask) + # + data[[0,1,2,-1]] = masked + record = data.torecords() + assert_equal(record['_data'], data._data) + assert_equal(record['_mask'], data._mask) + # + ndtype = [('i',int), ('s','|S3'), ('f',float)] + data = array([(i,s,f) for (i,s,f) in zip(np.arange(10), + 'ABCDEFGHIJKLM', + np.random.rand(10))], + dtype=ndtype) + data[[0,1,2,-1]] = masked + record = data.torecords() + assert_equal(record['_data'], data._data) + assert_equal(record['_mask'], data._mask) + # + ndtype = np.dtype("int, (2,3)float, float") + data = array([(i,f,ff) for (i,f,ff) in zip(np.arange(10), + np.random.rand(10), + np.random.rand(10))], + dtype=ndtype) + data[[0,1,2,-1]] = masked + record = data.torecords() + assert_equal(record['_data'], data._data) + assert_equal(record['_mask'], data._mask) + #------------------------------------------------------------------------------ From numpy-svn at scipy.org Fri Jul 18 08:32:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 18 Jul 2008 07:32:30 -0500 (CDT) Subject: [Numpy-svn] r5450 - trunk/numpy/testing Message-ID: <20080718123230.E337339C23D@scipy.org> Author: alan.mcintyre Date: 2008-07-18 07:32:27 -0500 (Fri, 18 Jul 2008) New Revision: 5450 Added: trunk/numpy/testing/noseclasses.py Modified: trunk/numpy/testing/nosetester.py Log: Use a subclass of the nose doctest plugin instead of monkeypatching the builtin plugin. Removed decorators for NoseTester methods. Added: trunk/numpy/testing/noseclasses.py =================================================================== --- trunk/numpy/testing/noseclasses.py 2008-07-18 02:02:19 UTC (rev 5449) +++ trunk/numpy/testing/noseclasses.py 2008-07-18 12:32:27 UTC (rev 5450) @@ -0,0 +1,249 @@ +# These classes implement a doctest runner plugin for nose. +# Because this module imports nose directly, it should not +# be used except by nosetester.py to avoid a general NumPy +# dependency on nose. + +import os +import doctest + +from nose.plugins import doctests as npd +from nose.plugins.base import Plugin +from nose.util import src, tolist +import numpy +from nosetester import get_package_name +import inspect + +_doctest_ignore = ['generate_numpy_api.py', 'scons_support.py', + 'setupscons.py', 'setup.py'] + +# All the classes in this module begin with 'numpy' to clearly distinguish them +# from the plethora of very similar names from nose/unittest/doctest + + +#----------------------------------------------------------------------------- +# Modified version of the one in the stdlib, that fixes a python bug (doctests +# not found in extension modules, http://bugs.python.org/issue3158) +class numpyDocTestFinder(doctest.DocTestFinder): + + def _from_module(self, module, object): + """ + Return true if the given object is defined in the given + module. + """ + if module is None: + #print '_fm C1' # dbg + return True + elif inspect.isfunction(object): + #print '_fm C2' # dbg + return module.__dict__ is object.func_globals + elif inspect.isbuiltin(object): + #print '_fm C2-1' # dbg + return module.__name__ == object.__module__ + elif inspect.isclass(object): + #print '_fm C3' # dbg + return module.__name__ == object.__module__ + elif inspect.ismethod(object): + # This one may be a bug in cython that fails to correctly set the + # __module__ attribute of methods, but since the same error is easy + # to make by extension code writers, having this safety in place + # isn't such a bad idea + #print '_fm C3-1' # dbg + return module.__name__ == object.im_class.__module__ + elif inspect.getmodule(object) is not None: + #print '_fm C4' # dbg + #print 'C4 mod',module,'obj',object # dbg + return module is inspect.getmodule(object) + elif hasattr(object, '__module__'): + #print '_fm C5' # dbg + return module.__name__ == object.__module__ + elif isinstance(object, property): + #print '_fm C6' # dbg + return True # [XX] no way not be sure. + else: + raise ValueError("object must be a class or function") + + + + def _find(self, tests, obj, name, module, source_lines, globs, seen): + """ + Find tests for the given object and any contained objects, and + add them to `tests`. + """ + + doctest.DocTestFinder._find(self,tests, obj, name, module, + source_lines, globs, seen) + + # Below we re-run pieces of the above method with manual modifications, + # because the original code is buggy and fails to correctly identify + # doctests in extension modules. + + # Local shorthands + from inspect import isroutine, isclass, ismodule + + # Look for tests in a module's contained objects. + if inspect.ismodule(obj) and self._recurse: + for valname, val in obj.__dict__.items(): + valname1 = '%s.%s' % (name, valname) + if ( (isroutine(val) or isclass(val)) + and self._from_module(module, val) ): + + self._find(tests, val, valname1, module, source_lines, + globs, seen) + + + # Look for tests in a class's contained objects. + if inspect.isclass(obj) and self._recurse: + #print 'RECURSE into class:',obj # dbg + for valname, val in obj.__dict__.items(): + #valname1 = '%s.%s' % (name, valname) # dbg + #print 'N',name,'VN:',valname,'val:',str(val)[:77] # dbg + # Special handling for staticmethod/classmethod. + if isinstance(val, staticmethod): + val = getattr(obj, valname) + if isinstance(val, classmethod): + val = getattr(obj, valname).im_func + + # Recurse to methods, properties, and nested classes. + if ((inspect.isfunction(val) or inspect.isclass(val) or + inspect.ismethod(val) or + isinstance(val, property)) and + self._from_module(module, val)): + valname = '%s.%s' % (name, valname) + self._find(tests, val, valname, module, source_lines, + globs, seen) + + +class numpyDocTestCase(npd.DocTestCase): + """Proxy for DocTestCase: provides an address() method that + returns the correct address for the doctest case. Otherwise + acts as a proxy to the test case. To provide hints for address(), + an obj may also be passed -- this will be used as the test object + for purposes of determining the test address, if it is provided. + """ + + # doctests loaded via find(obj) omit the module name + # so we need to override id, __repr__ and shortDescription + # bonus: this will squash a 2.3 vs 2.4 incompatiblity + def id(self): + name = self._dt_test.name + filename = self._dt_test.filename + if filename is not None: + pk = getpackage(filename) + if pk is not None and not name.startswith(pk): + name = "%s.%s" % (pk, name) + return name + + +# second-chance checker; if the default comparison doesn't +# pass, then see if the expected output string contains flags that +# tell us to ignore the output +class numpyOutputChecker(doctest.OutputChecker): + def check_output(self, want, got, optionflags): + ret = doctest.OutputChecker.check_output(self, want, got, + optionflags) + if not ret: + if "#random" in want: + return True + + return ret + + +# Subclass nose.plugins.doctests.DocTestCase to work around a bug in +# its constructor that blocks non-default arguments from being passed +# down into doctest.DocTestCase +class numpyDocTestCase(npd.DocTestCase): + def __init__(self, test, optionflags=0, setUp=None, tearDown=None, + checker=None, obj=None, result_var='_'): + self._result_var = result_var + self._nose_obj = obj + doctest.DocTestCase.__init__(self, test, + optionflags=optionflags, + setUp=setUp, tearDown=tearDown, + checker=checker) + + +print_state = numpy.get_printoptions() + +class numpyDoctest(npd.Doctest): + name = 'numpydoctest' # call nosetests with --with-numpydoctest + enabled = True + + def options(self, parser, env=os.environ): + Plugin.options(self, parser, env) + + def configure(self, options, config): + Plugin.configure(self, options, config) + self.doctest_tests = True + self.extension = tolist(options.doctestExtension) + self.finder = numpyDocTestFinder() + self.parser = doctest.DocTestParser() + + # Turns on whitespace normalization, set a minimal execution context + # for doctests, implement a "#random" directive to allow executing a + # command while ignoring its output. + def loadTestsFromModule(self, module): + if not self.matches(module.__name__): + npd.log.debug("Doctest doesn't want module %s", module) + return + try: + tests = self.finder.find(module) + except AttributeError: + # nose allows module.__test__ = False; doctest does not and + # throws AttributeError + return + if not tests: + return + tests.sort() + module_file = src(module.__file__) + for test in tests: + if not test.examples: + continue + if not test.filename: + test.filename = module_file + + pkg_name = get_package_name(os.path.dirname(test.filename)) + + # Each doctest should execute in an environment equivalent to + # starting Python and executing "import numpy as np", and, + # for SciPy packages, an additional import of the local + # package (so that scipy.linalg.basic.py's doctests have an + # implicit "from scipy import linalg" as well. + # + # Note: __file__ allows the doctest in NoseTester to run + # without producing an error + test.globs = {'__builtins__':__builtins__, + '__file__':'__main__', + '__name__':'__main__', + 'np':numpy} + + # add appropriate scipy import for SciPy tests + if 'scipy' in pkg_name: + p = pkg_name.split('.') + p1 = '.'.join(p[:-1]) + p2 = p[-1] + test.globs[p2] = __import__(pkg_name, fromlist=[p2]) + + print 'additional import for %s: from %s import %s' % (test.filename, p1, p2) + print ' (%s): %r' % (pkg_name, test.globs[p2]) + + # always use whitespace and ellipsis options + optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS + + yield numpyDocTestCase(test, + optionflags=optionflags, + checker=numpyOutputChecker()) + + + # Add an afterContext method to nose.plugins.doctests.Doctest in order + # to restore print options to the original state after each doctest + def afterContext(self): + numpy.set_printoptions(**print_state) + + + # Implement a wantFile method so that we can ignore NumPy-specific + # build files that shouldn't be searched for tests + def wantFile(self, file): + bn = os.path.basename(file) + if bn in _doctest_ignore: + return False + return npd.Doctest.wantFile(self, file) Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-18 02:02:19 UTC (rev 5449) +++ trunk/numpy/testing/nosetester.py 2008-07-18 12:32:27 UTC (rev 5450) @@ -7,127 +7,28 @@ import sys import warnings -# Patches nose functionality to add NumPy-specific features -# Note: This class should only be instantiated if nose has already -# been successfully imported -class NoseCustomizer: - __patched = False +def get_package_name(filepath): + # find the package name given a path name that's part of the package + fullpath = filepath[:] + pkg_name = [] + while 'site-packages' in filepath: + filepath, p2 = os.path.split(filepath) + if p2 == 'site-packages': + break + pkg_name.append(p2) - def __init__(self): - if NoseCustomizer.__patched: - return + # if package name determination failed, just default to numpy/scipy + if not pkg_name: + if 'scipy' in fullpath: + return 'scipy' + else: + return 'numpy' - NoseCustomizer.__patched = True + # otherwise, reverse to get correct order and return + pkg_name.reverse() + return '.'.join(pkg_name) - # used to monkeypatch the nose doctest classes - def monkeypatch_method(cls): - def decorator(func): - setattr(cls, func.__name__, func) - return func - return decorator - from nose.plugins import doctests as npd - from nose.plugins.base import Plugin - from nose.util import src, tolist - import numpy - import doctest - - # second-chance checker; if the default comparison doesn't - # pass, then see if the expected output string contains flags that - # tell us to ignore the output - class NumpyDoctestOutputChecker(doctest.OutputChecker): - def check_output(self, want, got, optionflags): - ret = doctest.OutputChecker.check_output(self, want, got, - optionflags) - if not ret: - if "#random" in want: - return True - - return ret - - - # Subclass nose.plugins.doctests.DocTestCase to work around a bug in - # its constructor that blocks non-default arguments from being passed - # down into doctest.DocTestCase - class NumpyDocTestCase(npd.DocTestCase): - def __init__(self, test, optionflags=0, setUp=None, tearDown=None, - checker=None, obj=None, result_var='_'): - self._result_var = result_var - self._nose_obj = obj - doctest.DocTestCase.__init__(self, test, - optionflags=optionflags, - setUp=setUp, tearDown=tearDown, - checker=checker) - - - - # This will replace the existing loadTestsFromModule method of - # nose.plugins.doctests.Doctest. It turns on whitespace normalization, - # adds an implicit "import numpy as np" for doctests, and adds a - # "#random" directive to allow executing a command while ignoring its - # output. - @monkeypatch_method(npd.Doctest) - def loadTestsFromModule(self, module): - if not self.matches(module.__name__): - npd.log.debug("Doctest doesn't want module %s", module) - return - try: - tests = self.finder.find(module) - except AttributeError: - # nose allows module.__test__ = False; doctest does not and - # throws AttributeError - return - if not tests: - return - tests.sort() - module_file = src(module.__file__) - for test in tests: - if not test.examples: - continue - if not test.filename: - test.filename = module_file - - # Each doctest should execute in an environment equivalent to - # starting Python and executing "import numpy as np" - # - # Note: __file__ allows the doctest in NoseTester to run - # without producing an error - test.globs = {'__builtins__':__builtins__, - '__file__':'__main__', - '__name__':'__main__', - 'np':numpy} - - # always use whitespace and ellipsis options - optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS - - yield NumpyDocTestCase(test, - optionflags=optionflags, - checker=NumpyDoctestOutputChecker()) - - # get original print options - print_state = numpy.get_printoptions() - - # Add an afterContext method to nose.plugins.doctests.Doctest in order - # to restore print options to the original state after each doctest - @monkeypatch_method(npd.Doctest) - def afterContext(self): - numpy.set_printoptions(**print_state) - - # Replace the existing wantFile method of nose.plugins.doctests.Doctest - # so that we can ignore NumPy-specific build files that shouldn't - # be searched for tests - old_wantFile = npd.Doctest.wantFile - ignore_files = ['generate_numpy_api.py', 'scons_support.py', - 'setupscons.py', 'setup.py'] - def wantFile(self, file): - bn = os.path.basename(file) - if bn in ignore_files: - return False - return old_wantFile(self, file) - - npd.Doctest.wantFile = wantFile - - def import_nose(): """ Import nose only when needed. """ @@ -143,12 +44,11 @@ fine_nose = False if not fine_nose: - raise ImportError('Need nose >=%d.%d.%d for tests - see ' - 'http://somethingaboutorange.com/mrl/projects/nose' % - minimum_nose_version) + msg = 'Need nose >= %d.%d.%d for tests - see ' \ + 'http://somethingaboutorange.com/mrl/projects/nose' % \ + minimum_nose_version - # nose was successfully imported; make customizations for doctests - NoseCustomizer() + raise ImportError(msg) return nose @@ -160,7 +60,31 @@ import_nose().run(argv=['',file_to_run]) +# contructs NoseTester method docstrings +def _docmethod(meth, testtype): + test_header = \ + '''Parameters + ---------- + label : {'fast', 'full', '', attribute identifer} + Identifies the %(testtype)ss to run. This can be a string to + pass to the nosetests executable with the '-A' option, or one of + several special values. + Special values are: + 'fast' - the default - which corresponds to nosetests -A option + of 'not slow'. + 'full' - fast (as above) and slow %(testtype)ss as in the + no -A option to nosetests - same as '' + None or '' - run all %(testtype)ss + attribute_identifier - string passed directly to nosetests as '-A' + verbose : integer + verbosity value for test outputs, 1-10 + extra_argv : list + List with any extra args to pass to nosetests''' \ + % {'testtype': testtype} + + meth.__doc__ = meth.__doc__ % {'test_header':test_header} + class NoseTester(object): """ Nose test runner. @@ -201,60 +125,8 @@ # find the package name under test; this name is used to limit coverage # reporting (if enabled) - pkg_temp = package - pkg_name = [] - while 'site-packages' in pkg_temp: - pkg_temp, p2 = os.path.split(pkg_temp) - if p2 == 'site-packages': - break - pkg_name.append(p2) + self.package_name = get_package_name(package) - # if package name determination failed, just default to numpy/scipy - if not pkg_name: - if 'scipy' in self.package_path: - self.package_name = 'scipy' - else: - self.package_name = 'numpy' - else: - pkg_name.reverse() - self.package_name = '.'.join(pkg_name) - - def _add_doc(testtype): - ''' Decorator to add docstring to functions using test labels - - Parameters - ---------- - testtype : string - Type of test for function docstring - ''' - def docit(func): - test_header = \ - '''Parameters - ---------- - label : {'fast', 'full', '', attribute identifer} - Identifies %(testtype)s to run. This can be a string to pass to - the nosetests executable with the'-A' option, or one of - several special values. - Special values are: - 'fast' - the default - which corresponds to - nosetests -A option of - 'not slow'. - 'full' - fast (as above) and slow %(testtype)s as in - no -A option to nosetests - same as '' - None or '' - run all %(testtype)ss - attribute_identifier - string passed directly to - nosetests as '-A' - verbose : integer - verbosity value for test outputs, 1-10 - extra_argv : list - List with any extra args to pass to nosetests''' \ - % {'testtype': testtype} - func.__doc__ = func.__doc__ % { - 'test_header': test_header} - return func - return docit - - @_add_doc('(testtype)') def _test_argv(self, label, verbose, extra_argv): ''' Generate argv for nosetest command @@ -271,8 +143,8 @@ if extra_argv: argv += extra_argv return argv + - @_add_doc('test') def test(self, label='fast', verbose=1, extra_argv=None, doctests=False, coverage=False, **kwargs): ''' Run tests for module using nose @@ -285,7 +157,9 @@ (Requires the coverage module: http://nedbatchelder.com/code/modules/coverage.html) ''' - old_args = set(['level', 'verbosity', 'all', 'sys_argv', 'testcase_pattern']) + + old_args = set(['level', 'verbosity', 'all', 'sys_argv', + 'testcase_pattern']) unexpected_args = set(kwargs.keys()) - old_args if len(unexpected_args) > 0: ua = ', '.join(unexpected_args) @@ -316,7 +190,10 @@ argv = self._test_argv(label, verbose, extra_argv) if doctests: - argv+=['--with-doctest','--doctest-tests'] + argv += ['--with-numpydoctest'] + print "Running unit tests and doctests for %s" % self.package_name + else: + print "Running unit tests for %s" % self.package_name if coverage: argv+=['--cover-package=%s' % self.package_name, '--with-coverage', @@ -342,8 +219,8 @@ """ if self.testRunner is None: self.testRunner = nose.core.TextTestRunner(stream=self.config.stream, - verbosity=self.config.verbosity, - config=self.config) + verbosity=self.config.verbosity, + config=self.config) plug_runner = self.config.plugins.prepareTestRunner(self.testRunner) if plug_runner is not None: self.testRunner = plug_runner @@ -351,14 +228,21 @@ self.success = self.result.wasSuccessful() return self.success - # reset doctest state + # reset doctest state on every run import doctest doctest.master = None - - t = NumpyTestProgram(argv=argv, exit=False) + + import nose.plugins.builtin + from noseclasses import numpyDoctest + plugins = [numpyDoctest(), ] + for m, p in nose.plugins.builtin.builtins: + mod = __import__(m,fromlist=[p]) + plug = getattr(mod, p) + plugins.append(plug()) + + t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins) return t.result - @_add_doc('benchmark') def bench(self, label='fast', verbose=1, extra_argv=None): ''' Run benchmarks for module using nose @@ -368,9 +252,14 @@ argv += ['--match', r'(?:^|[\\b_\\.%s-])[Bb]ench' % os.sep] return nose.run(argv=argv) + # generate method docstrings + _docmethod(_test_argv, '(testtype)') + _docmethod(test, 'test') + _docmethod(bench, 'benchmark') + ######################################################################## -# Doctests for NumPy-specific doctest modifications +# Doctests for NumPy-specific nose/doctest modifications # try the #random directive on the output line def check_random_directive(): From numpy-svn at scipy.org Fri Jul 18 09:00:32 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 18 Jul 2008 08:00:32 -0500 (CDT) Subject: [Numpy-svn] r5451 - trunk/numpy/testing Message-ID: <20080718130032.C53C439C50C@scipy.org> Author: alan.mcintyre Date: 2008-07-18 08:00:29 -0500 (Fri, 18 Jul 2008) New Revision: 5451 Modified: trunk/numpy/testing/noseclasses.py trunk/numpy/testing/nosetester.py Log: Comment cleanup. Fixed __import__ calls for Python 2.4 (__import__ doesn't take keyword args in 2.4). Modified: trunk/numpy/testing/noseclasses.py =================================================================== --- trunk/numpy/testing/noseclasses.py 2008-07-18 12:32:27 UTC (rev 5450) +++ trunk/numpy/testing/noseclasses.py 2008-07-18 13:00:29 UTC (rev 5451) @@ -178,7 +178,7 @@ self.finder = numpyDocTestFinder() self.parser = doctest.DocTestParser() - # Turns on whitespace normalization, set a minimal execution context + # Turn on whitespace normalization, set a minimal execution context # for doctests, implement a "#random" directive to allow executing a # command while ignoring its output. def loadTestsFromModule(self, module): @@ -221,7 +221,7 @@ p = pkg_name.split('.') p1 = '.'.join(p[:-1]) p2 = p[-1] - test.globs[p2] = __import__(pkg_name, fromlist=[p2]) + test.globs[p2] = __import__(pkg_name, test.globs, {}, [p2]) print 'additional import for %s: from %s import %s' % (test.filename, p1, p2) print ' (%s): %r' % (pkg_name, test.globs[p2]) @@ -240,8 +240,7 @@ numpy.set_printoptions(**print_state) - # Implement a wantFile method so that we can ignore NumPy-specific - # build files that shouldn't be searched for tests + # Ignore NumPy-specific build files that shouldn't be searched for tests def wantFile(self, file): bn = os.path.basename(file) if bn in _doctest_ignore: Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-18 12:32:27 UTC (rev 5450) +++ trunk/numpy/testing/nosetester.py 2008-07-18 13:00:29 UTC (rev 5451) @@ -236,7 +236,7 @@ from noseclasses import numpyDoctest plugins = [numpyDoctest(), ] for m, p in nose.plugins.builtin.builtins: - mod = __import__(m,fromlist=[p]) + mod = __import__(m,globals(),{},[p]) plug = getattr(mod, p) plugins.append(plug()) From numpy-svn at scipy.org Fri Jul 18 21:12:16 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 18 Jul 2008 20:12:16 -0500 (CDT) Subject: [Numpy-svn] r5452 - in trunk/numpy: core distutils random Message-ID: <20080719011216.95E59C7C09B@scipy.org> Author: rkern Date: 2008-07-18 20:12:16 -0500 (Fri, 18 Jul 2008) New Revision: 5452 Modified: trunk/numpy/core/setup.py trunk/numpy/distutils/misc_util.py trunk/numpy/random/setup.py Log: Generate headers in the right place for inplace builds. Modified: trunk/numpy/core/setup.py =================================================================== --- trunk/numpy/core/setup.py 2008-07-18 13:00:29 UTC (rev 5451) +++ trunk/numpy/core/setup.py 2008-07-19 01:12:16 UTC (rev 5452) @@ -65,7 +65,10 @@ header_dir = 'include/numpy' # this is relative to config.path_in_package def generate_config_h(ext, build_dir): - target = join(build_dir,'config.h') + target = join(build_dir,header_dir,'config.h') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) if newer(__file__,target): config_cmd = config.get_config_cmd() log.info('Generating %s',target) @@ -159,7 +162,10 @@ def generate_numpyconfig_h(ext, build_dir): """Depends on config.h: generate_config_h has to be called before !""" - target = join(build_dir,'numpyconfig.h') + target = join(build_dir,header_dir,'numpyconfig.h') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) if newer(__file__,target): config_cmd = config.get_config_cmd() log.info('Generating %s',target) @@ -198,7 +204,7 @@ try: m = __import__(module_name) log.info('executing %s', script) - h_file, c_file, doc_file = m.generate_api(build_dir) + h_file, c_file, doc_file = m.generate_api(os.path.join(build_dir, header_dir)) finally: del sys.path[0] config.add_data_files((header_dir, h_file), @@ -210,7 +216,10 @@ generate_ufunc_api = generate_api_func('generate_ufunc_api') def generate_umath_c(ext,build_dir): - target = join(build_dir,'__umath_generated.c') + target = join(build_dir,header_dir,'__umath_generated.c') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) script = generate_umath_py if newer(script,target): f = open(target,'w') Modified: trunk/numpy/distutils/misc_util.py =================================================================== --- trunk/numpy/distutils/misc_util.py 2008-07-18 13:00:29 UTC (rev 5451) +++ trunk/numpy/distutils/misc_util.py 2008-07-19 01:12:16 UTC (rev 5452) @@ -114,9 +114,20 @@ def get_mathlibs(path=None): """Return the MATHLIB line from numpyconfig.h """ - if path is None: - path = os.path.join(get_numpy_include_dirs()[0], 'numpy') - config_file = os.path.join(path,'numpyconfig.h') + if path is not None: + config_file = os.path.join(path,'numpyconfig.h') + else: + # Look for the file in each of the numpy include directories. + dirs = get_numpy_include_dirs() + for path in dirs: + fn = os.path.join(path,'numpyconfig.h') + if os.path.exists(fn): + config_file = fn + break + else: + raise DistutilsError('numpyconfig.h not found in numpy include ' + 'dirs %r' % (dirs,)) + fid = open(config_file) mathlibs = [] s = '#define MATHLIB' Modified: trunk/numpy/random/setup.py =================================================================== --- trunk/numpy/random/setup.py 2008-07-18 13:00:29 UTC (rev 5451) +++ trunk/numpy/random/setup.py 2008-07-19 01:12:16 UTC (rev 5452) @@ -6,11 +6,7 @@ def generate_libraries(ext, build_dir): config_cmd = config.get_config_cmd() - if top_path is None: - libs = get_mathlibs() - else: - path = join(split(build_dir)[0],'core') - libs = get_mathlibs(path) + libs = get_mathlibs() tc = testcode_wincrypt() if config_cmd.try_run(tc): libs.append('Advapi32') From numpy-svn at scipy.org Sat Jul 19 00:23:54 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 18 Jul 2008 23:23:54 -0500 (CDT) Subject: [Numpy-svn] r5453 - trunk/numpy/core/src Message-ID: <20080719042354.2D4B939C164@scipy.org> Author: oliphant Date: 2008-07-18 23:23:52 -0500 (Fri, 18 Jul 2008) New Revision: 5453 Modified: trunk/numpy/core/src/scalartypes.inc.src Log: Fix other reference count leak pointed out in #848 due to missing DECREF for typecode. Modified: trunk/numpy/core/src/scalartypes.inc.src =================================================================== --- trunk/numpy/core/src/scalartypes.inc.src 2008-07-19 01:12:16 UTC (rev 5452) +++ trunk/numpy/core/src/scalartypes.inc.src 2008-07-19 04:23:52 UTC (rev 5453) @@ -1902,6 +1902,8 @@ int itemsize; void *dest, *src; + /* allow base-class (if any) to do conversion */ + /* If successful, this will jump to finish: */ _WORK at work@ if (!PyArg_ParseTuple(args, "|O", &obj)) { @@ -1909,7 +1911,8 @@ } typecode = PyArray_DescrFromType(PyArray_ at TYPE@); /* typecode is new reference and stolen by - PyArray_Scalar and others */ + PyArray_FromAny but not PyArray_Scalar + */ if (obj == NULL) { #if @default@ == 0 char *mem = malloc(sizeof(@name@)); @@ -1923,6 +1926,7 @@ obj = Py_None; robj = PyArray_Scalar(&obj, typecode, NULL); #endif + Py_DECREF(typecode); goto finish; } @@ -1930,12 +1934,20 @@ if ((arr == NULL) || (PyArray_NDIM(arr) > 0)) { return arr; } - robj = PyArray_Return((PyArrayObject *)arr); + /* 0-d array */ + robj = PyArray_ToScalar(PyArray_DATA(arr), (NPY_AO *)arr); + Py_DECREF(arr); finish: + /* Normal return */ if ((robj == NULL) || (robj->ob_type == type)) { return robj; } + + /* This return path occurs when the requested type is not created + but another scalar object is created instead (i.e. when + the base-class does the conversion in _WORK macro) */ + /* Need to allocate new type and copy data-area over */ if (type->tp_itemsize) { itemsize = PyString_GET_SIZE(robj); @@ -1948,20 +1960,19 @@ Py_DECREF(robj); return NULL; } - if (typecode == NULL) { - typecode = PyArray_DescrFromType(PyArray_ at TYPE@); - } + /* typecode will be NULL */ + typecode = PyArray_DescrFromType(PyArray_ at TYPE@); dest = scalar_value(obj, typecode); src = scalar_value(robj, typecode); Py_DECREF(typecode); #if @default@ == 0 *((npy_ at name@ *)dest) = *((npy_ at name@ *)src); -#elif @default@ == 1 - if (itemsize == 0) { - itemsize = ((PyUnicodeObject *)robj)->length << 2; +#elif @default@ == 1 /* unicode and strings */ + if (itemsize == 0) { /* unicode */ + itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE); } memcpy(dest, src, itemsize); -#elif @default@ == 2 +#elif @default@ == 2 /* Object arrays */ memcpy(dest, src, sizeof(void *)); Py_INCREF(*((PyObject **)dest)); #endif From numpy-svn at scipy.org Sat Jul 19 09:50:19 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 19 Jul 2008 08:50:19 -0500 (CDT) Subject: [Numpy-svn] r5454 - trunk/numpy/testing Message-ID: <20080719135019.2E19339C164@scipy.org> Author: alan.mcintyre Date: 2008-07-19 08:50:16 -0500 (Sat, 19 Jul 2008) New Revision: 5454 Modified: trunk/numpy/testing/nosetester.py Log: Instead of importing nose plugins, use the existing list of classes that nose.plugins.builtins imports. If --with-doctest is included in extra_argv, remove it and use the NumPy doctester instead. Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-19 04:23:52 UTC (rev 5453) +++ trunk/numpy/testing/nosetester.py 2008-07-19 13:50:16 UTC (rev 5454) @@ -188,6 +188,12 @@ label = '' doctests = True + # if doctests is in the extra args, remove it and set the doctest + # flag so the NumPy doctester is used instead + if extra_argv and '--with-doctest' in extra_argv: + extra_argv.remove('--with-doctest') + doctests = True + argv = self._test_argv(label, verbose, extra_argv) if doctests: argv += ['--with-numpydoctest'] @@ -231,15 +237,18 @@ # reset doctest state on every run import doctest doctest.master = None - - import nose.plugins.builtin + + # construct list of plugins, omitting the existing doctest plugin + import nose.plugins.builtin from noseclasses import numpyDoctest - plugins = [numpyDoctest(), ] - for m, p in nose.plugins.builtin.builtins: - mod = __import__(m,globals(),{},[p]) - plug = getattr(mod, p) - plugins.append(plug()) + plugins = [numpyDoctest()] + for p in nose.plugins.builtin.plugins: + plug = p() + if plug.name == 'doctest': + continue + plugins.append(plug) + t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins) return t.result From numpy-svn at scipy.org Sat Jul 19 10:15:49 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 19 Jul 2008 09:15:49 -0500 (CDT) Subject: [Numpy-svn] r5455 - trunk/numpy/testing Message-ID: <20080719141549.C46DE39C164@scipy.org> Author: alan.mcintyre Date: 2008-07-19 09:15:47 -0500 (Sat, 19 Jul 2008) New Revision: 5455 Modified: trunk/numpy/testing/noseclasses.py Log: Comment out extension option since it is not used at present. Modified: trunk/numpy/testing/noseclasses.py =================================================================== --- trunk/numpy/testing/noseclasses.py 2008-07-19 13:50:16 UTC (rev 5454) +++ trunk/numpy/testing/noseclasses.py 2008-07-19 14:15:47 UTC (rev 5455) @@ -174,7 +174,7 @@ def configure(self, options, config): Plugin.configure(self, options, config) self.doctest_tests = True - self.extension = tolist(options.doctestExtension) +# self.extension = tolist(options.doctestExtension) self.finder = numpyDocTestFinder() self.parser = doctest.DocTestParser() From numpy-svn at scipy.org Sat Jul 19 13:22:35 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 19 Jul 2008 12:22:35 -0500 (CDT) Subject: [Numpy-svn] r5456 - branches/1.1.x/numpy/core/src Message-ID: <20080719172235.767E639C100@scipy.org> Author: charris Date: 2008-07-19 12:22:33 -0500 (Sat, 19 Jul 2008) New Revision: 5456 Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src Log: Fix arccosh and arcsinh implementations for complex numbers. Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src =================================================================== --- branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-19 14:15:47 UTC (rev 5455) +++ branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-19 17:22:33 UTC (rev 5456) @@ -825,16 +825,16 @@ c at typ@ t; nc_sum at c@(x, &nc_1 at c@, &t); + nc_sqrt at c@(&t, &t); nc_diff at c@(x, &nc_1 at c@, r); - nc_prod at c@(&t, r, r); nc_sqrt at c@(r, r); + nc_prod at c@(&t, r, r); nc_sum at c@(x, r, r); nc_log at c@(r, r); return; /* - return nc_log(nc_sum(x, - nc_sqrt(nc_prod(nc_sum(x,nc_1), nc_diff(x,nc_1))))); - */ + * log(x + sqrt(x + 1)*sqrt(x - 1) + */ } static void @@ -863,13 +863,12 @@ nc_prod at c@(x, x, r); nc_sum at c@(&nc_1 at c@, r, r); nc_sqrt at c@(r, r); - nc_diff at c@(r, x, r); + nc_sum at c@(r, x, r); nc_log at c@(r, r); - nc_neg at c@(r, r); return; /* - return nc_neg(nc_log(nc_diff(nc_sqrt(nc_sum(nc_1,nc_prod(x,x))),x))); - */ + * log(x + sqrt(1 + x**2)) + */ } static void From numpy-svn at scipy.org Sat Jul 19 17:56:52 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 19 Jul 2008 16:56:52 -0500 (CDT) Subject: [Numpy-svn] r5457 - trunk/numpy/core/src Message-ID: <20080719215652.0E44CC7C0E0@scipy.org> Author: ptvirtan Date: 2008-07-19 16:56:46 -0500 (Sat, 19 Jul 2008) New Revision: 5457 Modified: trunk/numpy/core/src/umathmodule.c.src Log: Fix arccosh branch cut. Remove one unnecessary operation from nc_asinh. Modified: trunk/numpy/core/src/umathmodule.c.src =================================================================== --- trunk/numpy/core/src/umathmodule.c.src 2008-07-19 17:22:33 UTC (rev 5456) +++ trunk/numpy/core/src/umathmodule.c.src 2008-07-19 21:56:46 UTC (rev 5457) @@ -825,15 +825,16 @@ c at typ@ t; nc_sum at c@(x, &nc_1 at c@, &t); + nc_sqrt at c@(&t, &t); nc_diff at c@(x, &nc_1 at c@, r); + nc_sqrt at c@(r, r); nc_prod at c@(&t, r, r); - nc_sqrt at c@(r, r); nc_sum at c@(x, r, r); nc_log at c@(r, r); return; /* return nc_log(nc_sum(x, - nc_sqrt(nc_prod(nc_sum(x,nc_1), nc_diff(x,nc_1))))); + nc_prod(nc_sqrt(nc_sum(x,nc_1)), nc_sqrt(nc_diff(x,nc_1))))); */ } @@ -863,12 +864,11 @@ nc_prod at c@(x, x, r); nc_sum at c@(&nc_1 at c@, r, r); nc_sqrt at c@(r, r); - nc_diff at c@(r, x, r); + nc_sum at c@(r, x, r); nc_log at c@(r, r); - nc_neg at c@(r, r); return; /* - return nc_neg(nc_log(nc_diff(nc_sqrt(nc_sum(nc_1,nc_prod(x,x))),x))); + return nc_log(nc_sum(nc_sqrt(nc_sum(nc_1,nc_prod(x,x))),x)); */ } From numpy-svn at scipy.org Sat Jul 19 17:58:21 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 19 Jul 2008 16:58:21 -0500 (CDT) Subject: [Numpy-svn] r5458 - trunk/numpy/core/tests Message-ID: <20080719215821.48DB639C2B4@scipy.org> Author: ptvirtan Date: 2008-07-19 16:58:14 -0500 (Sat, 19 Jul 2008) New Revision: 5458 Modified: trunk/numpy/core/tests/test_umath.py Log: Add tests for complex functions: test against Python's cmath, check the branch cuts and C99 compliance at inf, nan special points. Modified: trunk/numpy/core/tests/test_umath.py =================================================================== --- trunk/numpy/core/tests/test_umath.py 2008-07-19 21:56:46 UTC (rev 5457) +++ trunk/numpy/core/tests/test_umath.py 2008-07-19 21:58:14 UTC (rev 5458) @@ -1,6 +1,8 @@ from numpy.testing import * import numpy.core.umath as ncu import numpy as np +import nose +from numpy import inf, nan, pi class TestDivision(TestCase): def test_division_int(self): @@ -35,7 +37,6 @@ assert_almost_equal(x**14, [-76443+16124j, 23161315+58317492j, 5583548873 + 2465133864j]) - class TestLog1p(TestCase): def test_log1p(self): assert_almost_equal(ncu.log1p(0.2), ncu.log(1.2)) @@ -179,10 +180,10 @@ assert_equal(np.choose(c, (a, 1)), np.array([1,1])) -class TestComplexFunctions(TestCase): +class TestComplexFunctions(object): funcs = [np.arcsin , np.arccos , np.arctan, np.arcsinh, np.arccosh, np.arctanh, np.sin , np.cos , np.tan , np.exp, - np.log , np.sqrt , np.log10] + np.log , np.sqrt , np.log10, np.log1p] def test_it(self): for f in self.funcs: @@ -204,7 +205,206 @@ assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s'%f) assert_almost_equal(fcl, fcd, decimal=15, err_msg='fch-fcl %s'%f) + def test_branch_cuts(self): + # check branch cuts and continuity on them + yield _check_branch_cut, np.log, -0.5, 1j, 1, -1, True + yield _check_branch_cut, np.log10, -0.5, 1j, 1, -1, True + yield _check_branch_cut, np.log1p, -1.5, 1j, 1, -1, True + yield _check_branch_cut, np.sqrt, -0.5, 1j, 1, -1 + + yield _check_branch_cut, np.arcsin, [ -2, 2], [1j, -1j], 1, -1 + yield _check_branch_cut, np.arccos, [ -2, 2], [1j, -1j], 1, -1 + yield _check_branch_cut, np.arctan, [-2j, 2j], [1, -1 ], -1, 1 + + yield _check_branch_cut, np.arcsinh, [-2j, 2j], [-1, 1], -1, 1 + yield _check_branch_cut, np.arccosh, [ -1, 0.5], [1j, 1j], 1, -1 + yield _check_branch_cut, np.arctanh, [ -2, 2], [1j, -1j], 1, -1 + # check against bogus branch cuts: assert continuity between quadrants + yield _check_branch_cut, np.arcsin, [-2j, 2j], [ 1, 1], 1, 1 + yield _check_branch_cut, np.arccos, [-2j, 2j], [ 1, 1], 1, 1 + yield _check_branch_cut, np.arctan, [ -2, 2], [1j, 1j], 1, 1 + + yield _check_branch_cut, np.arcsinh, [ -2, 2, 0], [1j, 1j, 1 ], 1, 1 + yield _check_branch_cut, np.arccosh, [-2j, 2j, 2], [1, 1, 1j], 1, 1 + yield _check_branch_cut, np.arctanh, [-2j, 2j, 0], [1, 1, 1j], 1, 1 + + def test_branch_cuts_failing(self): + # XXX: signed zeros are not OK for sqrt or for the arc* functions + yield _check_branch_cut, np.sqrt, -0.5, 1j, 1, -1, True + yield _check_branch_cut, np.arcsin, [ -2, 2], [1j, -1j], 1, -1, True + yield _check_branch_cut, np.arccos, [ -2, 2], [1j, -1j], 1, -1, True + yield _check_branch_cut, np.arctan, [-2j, 2j], [1, -1 ], -1, 1, True + yield _check_branch_cut, np.arcsinh, [-2j, 2j], [-1, 1], -1, 1, True + yield _check_branch_cut, np.arccosh, [ -1, 0.5], [1j, 1j], 1, -1, True + yield _check_branch_cut, np.arctanh, [ -2, 2], [1j, -1j], 1, -1, True + test_branch_cuts_failing = dec.skipknownfailure(test_branch_cuts_failing) + + def test_against_cmath(self): + import cmath, sys + + # cmath.asinh is broken in some versions of Python, see + # http://bugs.python.org/issue1381 + broken_cmath_asinh = False + if sys.version_info < (2,5,3): + broken_cmath_asinh = True + + points = [-2, 2j, 2, -2j, -1-1j, -1+1j, +1-1j, +1+1j] + name_map = {'arcsin': 'asin', 'arccos': 'acos', 'arctan': 'atan', + 'arcsinh': 'asinh', 'arccosh': 'acosh', 'arctanh': 'atanh'} + atol = 4*np.finfo(np.complex).eps + for func in self.funcs: + fname = func.__name__.split('.')[-1] + cname = name_map.get(fname, fname) + try: cfunc = getattr(cmath, cname) + except AttributeError: continue + for p in points: + a = complex(func(np.complex_(p))) + b = cfunc(p) + + if cname == 'asinh' and broken_cmath_asinh: + continue + + assert abs(a - b) < atol, "%s %s: %s; cmath: %s"%(fname,p,a,b) + +class TestC99(object): + """Check special functions at special points against the C99 standard""" + # NB: inherits from object instead of TestCase since using test generators + + # + # Non-conforming results are with XXX added to the exception field. + # + + def test_clog(self): + for p, v, e in [ + ((-0., 0.), (-inf, pi), 'divide'), + ((+0., 0.), (-inf, 0.), 'divide'), + ((1., inf), (inf, pi/2), ''), + ((1., nan), (nan, nan), ''), + ((-inf, 1.), (inf, pi), ''), + ((inf, 1.), (inf, 0.), ''), + ((-inf, inf), (inf, 3*pi/4), ''), + ((inf, inf), (inf, pi/4), ''), + ((inf, nan), (inf, nan), ''), + ((-inf, nan), (inf, nan), ''), + ((nan, 0.), (nan, nan), ''), + ((nan, 1.), (nan, nan), ''), + ((nan, inf), (inf, nan), ''), + ((+nan, nan), (nan, nan), ''), + ]: + yield self._check, np.log, p, v, e + + def test_csqrt(self): + for p, v, e in [ + ((-0., 0.), (0.,0.), 'XXX'), # now (-0., 0.) + ((0., 0.), (0.,0.), ''), + ((1., inf), (inf,inf), 'XXX invalid'), # now (inf, nan) + ((nan, inf), (inf,inf), 'XXX'), # now (nan, nan) + ((-inf, 1.), (0.,inf), ''), + ((inf, 1.), (inf,0.), ''), + ((-inf,nan), (nan, -inf), ''), # could also be +inf + ((inf, nan), (inf, nan), ''), + ((nan, 1.), (nan, nan), ''), + ((nan, nan), (nan, nan), ''), + ]: + yield self._check, np.sqrt, p, v, e + + def test_cacos(self): + for p, v, e in [ + ((0., 0.), (pi/2, -0.), 'XXX'), # now (-0., 0.) + ((-0., 0.), (pi/2, -0.), ''), + ((0., nan), (pi/2, nan), 'XXX'), # now (nan, nan) + ((-0., nan), (pi/2, nan), 'XXX'), # now (nan, nan) + ((1., inf), (pi/2, -inf), 'XXX'), # now (nan, -inf) + ((1., nan), (nan, nan), ''), + ((-inf, 1.), (pi, -inf), 'XXX'), # now (nan, -inf) + ((inf, 1.), (0., -inf), 'XXX'), # now (nan, -inf) + ((-inf, inf), (3*pi/4, -inf), 'XXX'), # now (nan, nan) + ((inf, inf), (pi/4, -inf), 'XXX'), # now (nan, nan) + ((inf, nan), (nan, +-inf), 'XXX'), # now (nan, nan) + ((-inf, nan), (nan, +-inf), 'XXX'), # now: (nan, nan) + ((nan, 1.), (nan, nan), ''), + ((nan, inf), (nan, -inf), 'XXX'), # now: (nan, nan) + ((nan, nan), (nan, nan), ''), + ]: + yield self._check, np.arccos, p, v, e + + def test_cacosh(self): + for p, v, e in [ + ((0., 0), (0, pi/2), ''), + ((-0., 0), (0, pi/2), ''), + ((1., inf), (inf, pi/2), 'XXX'), # now: (nan, nan) + ((1., nan), (nan, nan), ''), + ((-inf, 1.), (inf, pi), 'XXX'), # now: (inf, nan) + ((inf, 1.), (inf, 0.), 'XXX'), # now: (inf, nan) + ((-inf, inf), (inf, 3*pi/4), 'XXX'), # now: (nan, nan) + ((inf, inf), (inf, pi/4), 'XXX'), # now: (nan, nan) + ((inf, nan), (inf, nan), 'XXX'), # now: (nan, nan) + ((-inf, nan), (inf, nan), 'XXX'), # now: (nan, nan) + ((nan, 1.), (nan, nan), ''), + ((nan, inf), (inf, nan), 'XXX'), # now: (nan, nan) + ((nan, nan), (nan, nan), '') + ]: + yield self._check, np.arccosh, p, v, e + + def test_casinh(self): + for p, v, e in [ + ((0., 0), (0, 0), ''), + ((1., inf), (inf, pi/2), 'XXX'), # now: (inf, nan) + ((1., nan), (nan, nan), ''), + ((inf, 1.), (inf, 0.), 'XXX'), # now: (inf, nan) + ((inf, inf), (inf, pi/4), 'XXX'), # now: (nan, nan) + ((inf, nan), (nan, nan), 'XXX'), # now: (nan, nan) + ((nan, 0.), (nan, 0.), 'XXX'), # now: (nan, nan) + ((nan, 1.), (nan, nan), ''), + ((nan, inf), (+-inf, nan), 'XXX'), # now: (nan, nan) + ((nan, nan), (nan, nan), ''), + ]: + yield self._check, np.arcsinh, p, v, e + + def test_catanh(self): + for p, v, e in [ + ((0., 0), (0, 0), ''), + ((0., nan), (0., nan), 'XXX'), # now: (nan, nan) + ((1., 0.), (inf, 0.), 'XXX divide'), # now: (nan, nan) + ((1., inf), (inf, 0.), 'XXX'), # now: (nan, nan) + ((1., nan), (nan, nan), ''), + ((inf, 1.), (0., pi/2), 'XXX'), # now: (nan, nan) + ((inf, inf), (0, pi/2), 'XXX'), # now: (nan, nan) + ((inf, nan), (0, nan), 'XXX'), # now: (nan, nan) + ((nan, 1.), (nan, nan), ''), + ((nan, inf), (+0, pi/2), 'XXX'), # now: (nan, nan) + ((nan, nan), (nan, nan), ''), + ]: + yield self._check, np.arctanh, p, v, e + + def _check(self, func, point, value, exc=''): + if 'XXX' in exc: + raise nose.SkipTest + if isinstance(point, tuple): point = complex(*point) + if isinstance(value, tuple): value = complex(*value) + v = dict(divide='ignore', invalid='ignore', + over='ignore', under='ignore') + old_err = np.seterr(**v) + try: + # check sign of zero, nan, etc. + got = complex(func(point)) + got = "(%s, %s)" % (repr(got.real), repr(got.imag)) + expected = "(%s, %s)" % (repr(value.real), repr(value.imag)) + assert got == expected, (got, expected) + + # check exceptions + if exc in ('divide', 'invalid', 'over', 'under'): + v[exc] = 'raise' + np.seterr(**v) + assert_raises(FloatingPointError, func, point) + else: + for k in v.keys(): v[k] = 'raise' + np.seterr(**v) + func(point) + finally: + np.seterr(**old_err) + class TestAttributes(TestCase): def test_attributes(self): add = ncu.add @@ -216,6 +416,59 @@ assert_equal(add.nout, 1) assert_equal(add.identity, 0) +def _check_branch_cut(f, x0, dx, re_sign=1, im_sign=-1, sig_zero_ok=False, + dtype=np.complex): + """ + Check for a branch cut in a function. + Assert that `x0` lies on a branch cut of function `f` and `f` is + continuous from the direction `dx`. + + Parameters + ---------- + f : func + Function to check + x0 : array-like + Point on branch cut + dx : array-like + Direction to check continuity in + re_sign, im_sign : {1, -1} + Change of sign of the real or imaginary part expected + sig_zero_ok : bool + Whether to check if the branch cut respects signed zero (if applicable) + dtype : dtype + Dtype to check (should be complex) + + """ + x0 = np.atleast_1d(x0).astype(dtype) + dx = np.atleast_1d(dx).astype(dtype) + + scale = np.finfo(dtype).eps * 1e3 + atol = 1e-4 + + y0 = f(x0) + yp = f(x0 + dx*scale*np.absolute(x0)/np.absolute(dx)) + ym = f(x0 - dx*scale*np.absolute(x0)/np.absolute(dx)) + + assert np.all(np.absolute(y0.real - yp.real) < atol), (y0, yp) + assert np.all(np.absolute(y0.imag - yp.imag) < atol), (y0, yp) + assert np.all(np.absolute(y0.real - ym.real*re_sign) < atol), (y0, ym) + assert np.all(np.absolute(y0.imag - ym.imag*im_sign) < atol), (y0, ym) + + if sig_zero_ok: + # check that signed zeros also work as a displacement + jr = (x0.real == 0) & (dx.real != 0) + ji = (x0.imag == 0) & (dx.imag != 0) + + x = -x0 + x.real[jr] = 0.*dx.real + x.imag[ji] = 0.*dx.imag + x = -x + ym = f(x) + ym = ym[jr | ji] + y0 = y0[jr | ji] + assert np.all(np.absolute(y0.real - ym.real*re_sign) < atol), (y0, ym) + assert np.all(np.absolute(y0.imag - ym.imag*im_sign) < atol), (y0, ym) + if __name__ == "__main__": run_module_suite() From numpy-svn at scipy.org Sat Jul 19 18:47:19 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 19 Jul 2008 17:47:19 -0500 (CDT) Subject: [Numpy-svn] r5459 - trunk/numpy/core/tests Message-ID: <20080719224719.6C6C7C7C010@scipy.org> Author: ptvirtan Date: 2008-07-19 17:47:12 -0500 (Sat, 19 Jul 2008) New Revision: 5459 Modified: trunk/numpy/core/tests/test_umath.py Log: Fix some errors in C99 tests. Skip tests failing on Sparc64 Modified: trunk/numpy/core/tests/test_umath.py =================================================================== --- trunk/numpy/core/tests/test_umath.py 2008-07-19 21:58:14 UTC (rev 5458) +++ trunk/numpy/core/tests/test_umath.py 2008-07-19 22:47:12 UTC (rev 5459) @@ -302,10 +302,10 @@ ((nan, inf), (inf,inf), 'XXX'), # now (nan, nan) ((-inf, 1.), (0.,inf), ''), ((inf, 1.), (inf,0.), ''), - ((-inf,nan), (nan, -inf), ''), # could also be +inf + ((-inf,nan), (nan, -inf), 'XXX'), # could also be +inf. raises 'invalid' on Sparc64 ((inf, nan), (inf, nan), ''), - ((nan, 1.), (nan, nan), ''), - ((nan, nan), (nan, nan), ''), + ((nan, 1.), (nan, nan), 'invalid-optional'), + ((nan, nan), (nan, nan), 'XXX'), # raises 'invalid' on Sparc64 ]: yield self._check, np.sqrt, p, v, e @@ -316,16 +316,16 @@ ((0., nan), (pi/2, nan), 'XXX'), # now (nan, nan) ((-0., nan), (pi/2, nan), 'XXX'), # now (nan, nan) ((1., inf), (pi/2, -inf), 'XXX'), # now (nan, -inf) - ((1., nan), (nan, nan), ''), + ((1., nan), (nan, nan), 'invalid-optional'), ((-inf, 1.), (pi, -inf), 'XXX'), # now (nan, -inf) ((inf, 1.), (0., -inf), 'XXX'), # now (nan, -inf) ((-inf, inf), (3*pi/4, -inf), 'XXX'), # now (nan, nan) ((inf, inf), (pi/4, -inf), 'XXX'), # now (nan, nan) ((inf, nan), (nan, +-inf), 'XXX'), # now (nan, nan) ((-inf, nan), (nan, +-inf), 'XXX'), # now: (nan, nan) - ((nan, 1.), (nan, nan), ''), + ((nan, 1.), (nan, nan), 'invalid-optional'), ((nan, inf), (nan, -inf), 'XXX'), # now: (nan, nan) - ((nan, nan), (nan, nan), ''), + ((nan, nan), (nan, nan), 'XXX'), # raises 'invalid' on Sparc64 ]: yield self._check, np.arccos, p, v, e @@ -334,16 +334,16 @@ ((0., 0), (0, pi/2), ''), ((-0., 0), (0, pi/2), ''), ((1., inf), (inf, pi/2), 'XXX'), # now: (nan, nan) - ((1., nan), (nan, nan), ''), + ((1., nan), (nan, nan), 'invalid-optional'), ((-inf, 1.), (inf, pi), 'XXX'), # now: (inf, nan) ((inf, 1.), (inf, 0.), 'XXX'), # now: (inf, nan) ((-inf, inf), (inf, 3*pi/4), 'XXX'), # now: (nan, nan) ((inf, inf), (inf, pi/4), 'XXX'), # now: (nan, nan) ((inf, nan), (inf, nan), 'XXX'), # now: (nan, nan) ((-inf, nan), (inf, nan), 'XXX'), # now: (nan, nan) - ((nan, 1.), (nan, nan), ''), + ((nan, 1.), (nan, nan), 'invalid-optional'), ((nan, inf), (inf, nan), 'XXX'), # now: (nan, nan) - ((nan, nan), (nan, nan), '') + ((nan, nan), (nan, nan), 'XXX') # raises 'invalid' on Sparc64 ]: yield self._check, np.arccosh, p, v, e @@ -351,14 +351,14 @@ for p, v, e in [ ((0., 0), (0, 0), ''), ((1., inf), (inf, pi/2), 'XXX'), # now: (inf, nan) - ((1., nan), (nan, nan), ''), + ((1., nan), (nan, nan), 'invalid-optional'), ((inf, 1.), (inf, 0.), 'XXX'), # now: (inf, nan) ((inf, inf), (inf, pi/4), 'XXX'), # now: (nan, nan) ((inf, nan), (nan, nan), 'XXX'), # now: (nan, nan) ((nan, 0.), (nan, 0.), 'XXX'), # now: (nan, nan) - ((nan, 1.), (nan, nan), ''), + ((nan, 1.), (nan, nan), 'invalid-optional'), ((nan, inf), (+-inf, nan), 'XXX'), # now: (nan, nan) - ((nan, nan), (nan, nan), ''), + ((nan, nan), (nan, nan), 'XXX'), # raises 'invalid' on Sparc64 ]: yield self._check, np.arcsinh, p, v, e @@ -368,11 +368,11 @@ ((0., nan), (0., nan), 'XXX'), # now: (nan, nan) ((1., 0.), (inf, 0.), 'XXX divide'), # now: (nan, nan) ((1., inf), (inf, 0.), 'XXX'), # now: (nan, nan) - ((1., nan), (nan, nan), ''), + ((1., nan), (nan, nan), 'invalid-optional'), ((inf, 1.), (0., pi/2), 'XXX'), # now: (nan, nan) ((inf, inf), (0, pi/2), 'XXX'), # now: (nan, nan) ((inf, nan), (0, nan), 'XXX'), # now: (nan, nan) - ((nan, 1.), (nan, nan), ''), + ((nan, 1.), (nan, nan), 'invalid-optional'), ((nan, inf), (+0, pi/2), 'XXX'), # now: (nan, nan) ((nan, nan), (nan, nan), ''), ]: @@ -400,6 +400,7 @@ assert_raises(FloatingPointError, func, point) else: for k in v.keys(): v[k] = 'raise' + if exc == 'invalid-optional': v['invalid'] = 'ignore' np.seterr(**v) func(point) finally: From numpy-svn at scipy.org Sat Jul 19 22:16:37 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 19 Jul 2008 21:16:37 -0500 (CDT) Subject: [Numpy-svn] r5460 - branches/1.1.x/numpy/core/src Message-ID: <20080720021637.273EA39C05F@scipy.org> Author: charris Date: 2008-07-19 21:16:34 -0500 (Sat, 19 Jul 2008) New Revision: 5460 Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src Log: Backport fix for #848 by copying whole scalartypes.inc.src from trunk. Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src =================================================================== --- branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-19 22:47:12 UTC (rev 5459) +++ branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-20 02:16:34 UTC (rev 5460) @@ -6,8 +6,8 @@ #include "numpy/arrayscalars.h" static PyBoolScalarObject _PyArrayScalar_BoolValues[2] = { - {PyObject_HEAD_INIT(&PyBoolArrType_Type) 0}, - {PyObject_HEAD_INIT(&PyBoolArrType_Type) 1}, + {PyObject_HEAD_INIT(&PyBoolArrType_Type) 0}, + {PyObject_HEAD_INIT(&PyBoolArrType_Type) 1}, }; /* Inheritance established later when tp_bases is set (or tp_base for @@ -20,109 +20,110 @@ */ static PyTypeObject Py at NAME@ArrType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "numpy. at name@", /*tp_name*/ - sizeof(PyObject), /*tp_basicsize*/ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "numpy. at name@", /*tp_name*/ + sizeof(PyObject), /*tp_basicsize*/ }; /**end repeat**/ static void * scalar_value(PyObject *scalar, PyArray_Descr *descr) { - int type_num; - int align; - intp memloc; - if (descr == NULL) { - descr = PyArray_DescrFromScalar(scalar); - type_num = descr->type_num; - Py_DECREF(descr); - } else { - type_num = descr->type_num; - } - switch (type_num) { + int type_num; + int align; + intp memloc; + if (descr == NULL) { + descr = PyArray_DescrFromScalar(scalar); + type_num = descr->type_num; + Py_DECREF(descr); + } + else { + type_num = descr->type_num; + } + switch (type_num) { #define CASE(ut,lt) case NPY_##ut: return &(((Py##lt##ScalarObject *)scalar)->obval) - CASE(BOOL, Bool); - CASE(BYTE, Byte); - CASE(UBYTE, UByte); - CASE(SHORT, Short); - CASE(USHORT, UShort); - CASE(INT, Int); - CASE(UINT, UInt); - CASE(LONG, Long); - CASE(ULONG, ULong); - CASE(LONGLONG, LongLong); - CASE(ULONGLONG, ULongLong); - CASE(FLOAT, Float); - CASE(DOUBLE, Double); - CASE(LONGDOUBLE, LongDouble); - CASE(CFLOAT, CFloat); - CASE(CDOUBLE, CDouble); - CASE(CLONGDOUBLE, CLongDouble); - CASE(OBJECT, Object); + CASE(BOOL, Bool); + CASE(BYTE, Byte); + CASE(UBYTE, UByte); + CASE(SHORT, Short); + CASE(USHORT, UShort); + CASE(INT, Int); + CASE(UINT, UInt); + CASE(LONG, Long); + CASE(ULONG, ULong); + CASE(LONGLONG, LongLong); + CASE(ULONGLONG, ULongLong); + CASE(FLOAT, Float); + CASE(DOUBLE, Double); + CASE(LONGDOUBLE, LongDouble); + CASE(CFLOAT, CFloat); + CASE(CDOUBLE, CDouble); + CASE(CLONGDOUBLE, CLongDouble); + CASE(OBJECT, Object); #undef CASE case NPY_STRING: return (void *)PyString_AS_STRING(scalar); case NPY_UNICODE: return (void *)PyUnicode_AS_DATA(scalar); case NPY_VOID: return ((PyVoidScalarObject *)scalar)->obval; - } + } - /* Must be a user-defined type --- check to see which - scalar it inherits from. */ + /* Must be a user-defined type --- check to see which + scalar it inherits from. */ #define _CHK(cls) (PyObject_IsInstance(scalar, \ - (PyObject *)&Py##cls##ArrType_Type)) + (PyObject *)&Py##cls##ArrType_Type)) #define _OBJ(lt) &(((Py##lt##ScalarObject *)scalar)->obval) #define _IFCASE(cls) if _CHK(cls) return _OBJ(cls) - if _CHK(Number) { - if _CHK(Integer) { - if _CHK(SignedInteger) { - _IFCASE(Byte); - _IFCASE(Short); - _IFCASE(Int); - _IFCASE(Long); - _IFCASE(LongLong); - } - else { /* Unsigned Integer */ - _IFCASE(UByte); - _IFCASE(UShort); - _IFCASE(UInt); - _IFCASE(ULong); - _IFCASE(ULongLong); - } - } - else { /* Inexact */ - if _CHK(Floating) { - _IFCASE(Float); - _IFCASE(Double); - _IFCASE(LongDouble); - } - else { /*ComplexFloating */ - _IFCASE(CFloat); - _IFCASE(CDouble); - _IFCASE(CLongDouble); - } - } + if _CHK(Number) { + if _CHK(Integer) { + if _CHK(SignedInteger) { + _IFCASE(Byte); + _IFCASE(Short); + _IFCASE(Int); + _IFCASE(Long); + _IFCASE(LongLong); + } + else { /* Unsigned Integer */ + _IFCASE(UByte); + _IFCASE(UShort); + _IFCASE(UInt); + _IFCASE(ULong); + _IFCASE(ULongLong); + } } - else if _CHK(Bool) return _OBJ(Bool); - else if _CHK(Flexible) { - if _CHK(String) return (void *)PyString_AS_STRING(scalar); - if _CHK(Unicode) return (void *)PyUnicode_AS_DATA(scalar); - if _CHK(Void) return ((PyVoidScalarObject *)scalar)->obval; + else { /* Inexact */ + if _CHK(Floating) { + _IFCASE(Float); + _IFCASE(Double); + _IFCASE(LongDouble); + } + else { /*ComplexFloating */ + _IFCASE(CFloat); + _IFCASE(CDouble); + _IFCASE(CLongDouble); + } } - else _IFCASE(Object); + } + else if _CHK(Bool) return _OBJ(Bool); + else if _CHK(Flexible) { + if _CHK(String) return (void *)PyString_AS_STRING(scalar); + if _CHK(Unicode) return (void *)PyUnicode_AS_DATA(scalar); + if _CHK(Void) return ((PyVoidScalarObject *)scalar)->obval; + } + else _IFCASE(Object); - /* Use the alignment flag to figure out where the data begins - after a PyObject_HEAD - */ - memloc = (intp)scalar; - memloc += sizeof(PyObject); - /* now round-up to the nearest alignment value - */ - align = descr->alignment; - if (align > 1) memloc = ((memloc + align - 1)/align)*align; - return (void *)memloc; + /* Use the alignment flag to figure out where the data begins + after a PyObject_HEAD + */ + memloc = (intp)scalar; + memloc += sizeof(PyObject); + /* now round-up to the nearest alignment value + */ + align = descr->alignment; + if (align > 1) memloc = ((memloc + align - 1)/align)*align; + return (void *)memloc; #undef _IFCASE #undef _OBJ #undef _CHK @@ -137,19 +138,19 @@ static void PyArray_ScalarAsCtype(PyObject *scalar, void *ctypeptr) { - PyArray_Descr *typecode; - void *newptr; - typecode = PyArray_DescrFromScalar(scalar); - newptr = scalar_value(scalar, typecode); + PyArray_Descr *typecode; + void *newptr; + typecode = PyArray_DescrFromScalar(scalar); + newptr = scalar_value(scalar, typecode); - if (PyTypeNum_ISEXTENDED(typecode->type_num)) { - void **ct = (void **)ctypeptr; - *ct = newptr; - } else { - memcpy(ctypeptr, newptr, typecode->elsize); - } - Py_DECREF(typecode); - return; + if (PyTypeNum_ISEXTENDED(typecode->type_num)) { + void **ct = (void **)ctypeptr; + *ct = newptr; + } else { + memcpy(ctypeptr, newptr, typecode->elsize); + } + Py_DECREF(typecode); + return; } /* The output buffer must be large-enough to receive the value */ @@ -167,34 +168,37 @@ PyArray_CastScalarToCtype(PyObject *scalar, void *ctypeptr, PyArray_Descr *outcode) { - PyArray_Descr* descr; - PyArray_VectorUnaryFunc* castfunc; + PyArray_Descr* descr; + PyArray_VectorUnaryFunc* castfunc; - descr = PyArray_DescrFromScalar(scalar); - castfunc = PyArray_GetCastFunc(descr, outcode->type_num); - if (castfunc == NULL) return -1; - if (PyTypeNum_ISEXTENDED(descr->type_num) || + descr = PyArray_DescrFromScalar(scalar); + castfunc = PyArray_GetCastFunc(descr, outcode->type_num); + if (castfunc == NULL) return -1; + if (PyTypeNum_ISEXTENDED(descr->type_num) || PyTypeNum_ISEXTENDED(outcode->type_num)) { - PyArrayObject *ain, *aout; + PyArrayObject *ain, *aout; - ain = (PyArrayObject *)PyArray_FromScalar(scalar, NULL); - if (ain == NULL) {Py_DECREF(descr); return -1;} - aout = (PyArrayObject *) - PyArray_NewFromDescr(&PyArray_Type, - outcode, - 0, NULL, - NULL, ctypeptr, - CARRAY, NULL); - if (aout == NULL) {Py_DECREF(ain); return -1;} - castfunc(ain->data, aout->data, 1, ain, aout); - Py_DECREF(ain); - Py_DECREF(aout); + ain = (PyArrayObject *)PyArray_FromScalar(scalar, NULL); + if (ain == NULL) { + Py_DECREF(descr); + return -1; } - else { - castfunc(scalar_value(scalar, descr), ctypeptr, 1, NULL, NULL); - } - Py_DECREF(descr); - return 0; + aout = (PyArrayObject *) + PyArray_NewFromDescr(&PyArray_Type, + outcode, + 0, NULL, + NULL, ctypeptr, + CARRAY, NULL); + if (aout == NULL) {Py_DECREF(ain); return -1;} + castfunc(ain->data, aout->data, 1, ain, aout); + Py_DECREF(ain); + Py_DECREF(aout); + } + else { + castfunc(scalar_value(scalar, descr), ctypeptr, 1, NULL, NULL); + } + Py_DECREF(descr); + return 0; } /*NUMPY_API @@ -204,13 +208,13 @@ PyArray_CastScalarDirect(PyObject *scalar, PyArray_Descr *indescr, void *ctypeptr, int outtype) { - PyArray_VectorUnaryFunc* castfunc; - void *ptr; - castfunc = PyArray_GetCastFunc(indescr, outtype); - if (castfunc == NULL) return -1; - ptr = scalar_value(scalar, indescr); - castfunc(ptr, ctypeptr, 1, NULL, NULL); - return 0; + PyArray_VectorUnaryFunc* castfunc; + void *ptr; + castfunc = PyArray_GetCastFunc(indescr, outtype); + if (castfunc == NULL) return -1; + ptr = scalar_value(scalar, indescr); + castfunc(ptr, ctypeptr, 1, NULL, NULL); + return 0; } /* 0-dim array from array-scalar object */ @@ -226,70 +230,70 @@ static PyObject * PyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode) { - PyArray_Descr *typecode; - PyObject *r; - char *memptr; - PyObject *ret; + PyArray_Descr *typecode; + PyObject *r; + char *memptr; + PyObject *ret; - /* convert to 0-dim array of scalar typecode */ - typecode = PyArray_DescrFromScalar(scalar); - if ((typecode->type_num == PyArray_VOID) && + /* convert to 0-dim array of scalar typecode */ + typecode = PyArray_DescrFromScalar(scalar); + if ((typecode->type_num == PyArray_VOID) && !(((PyVoidScalarObject *)scalar)->flags & OWNDATA) && outcode == NULL) { - r = PyArray_NewFromDescr(&PyArray_Type, - typecode, - 0, NULL, NULL, - ((PyVoidScalarObject *)scalar)->obval, - ((PyVoidScalarObject *)scalar)->flags, - NULL); - PyArray_BASE(r) = (PyObject *)scalar; - Py_INCREF(scalar); - return r; - } r = PyArray_NewFromDescr(&PyArray_Type, - typecode, - 0, NULL, - NULL, NULL, 0, NULL); - if (r==NULL) {Py_XDECREF(outcode); return NULL;} + typecode, + 0, NULL, NULL, + ((PyVoidScalarObject *)scalar)->obval, + ((PyVoidScalarObject *)scalar)->flags, + NULL); + PyArray_BASE(r) = (PyObject *)scalar; + Py_INCREF(scalar); + return r; + } + r = PyArray_NewFromDescr(&PyArray_Type, + typecode, + 0, NULL, + NULL, NULL, 0, NULL); + if (r==NULL) {Py_XDECREF(outcode); return NULL;} - if (PyDataType_FLAGCHK(typecode, NPY_USE_SETITEM)) { - if (typecode->f->setitem(scalar, PyArray_DATA(r), r) < 0) { - Py_XDECREF(outcode); Py_DECREF(r); - return NULL; - } - goto finish; + if (PyDataType_FLAGCHK(typecode, NPY_USE_SETITEM)) { + if (typecode->f->setitem(scalar, PyArray_DATA(r), r) < 0) { + Py_XDECREF(outcode); Py_DECREF(r); + return NULL; } + goto finish; + } - memptr = scalar_value(scalar, typecode); + memptr = scalar_value(scalar, typecode); #ifndef Py_UNICODE_WIDE - if (typecode->type_num == PyArray_UNICODE) { - PyUCS2Buffer_AsUCS4((Py_UNICODE *)memptr, - (PyArray_UCS4 *)PyArray_DATA(r), - PyUnicode_GET_SIZE(scalar), - PyArray_ITEMSIZE(r) >> 2); - } else + if (typecode->type_num == PyArray_UNICODE) { + PyUCS2Buffer_AsUCS4((Py_UNICODE *)memptr, + (PyArray_UCS4 *)PyArray_DATA(r), + PyUnicode_GET_SIZE(scalar), + PyArray_ITEMSIZE(r) >> 2); + } else #endif - { - memcpy(PyArray_DATA(r), memptr, PyArray_ITEMSIZE(r)); - if (PyDataType_FLAGCHK(typecode, NPY_ITEM_HASOBJECT)) { - Py_INCREF(*((PyObject **)memptr)); - } + { + memcpy(PyArray_DATA(r), memptr, PyArray_ITEMSIZE(r)); + if (PyDataType_FLAGCHK(typecode, NPY_ITEM_HASOBJECT)) { + Py_INCREF(*((PyObject **)memptr)); } + } - finish: - if (outcode == NULL) return r; +finish: + if (outcode == NULL) return r; - if (outcode->type_num == typecode->type_num) { - if (!PyTypeNum_ISEXTENDED(typecode->type_num) || - (outcode->elsize == typecode->elsize)) - return r; - } + if (outcode->type_num == typecode->type_num) { + if (!PyTypeNum_ISEXTENDED(typecode->type_num) || + (outcode->elsize == typecode->elsize)) + return r; + } - /* cast if necessary to desired output typecode */ - ret = PyArray_CastToType((PyArrayObject *)r, outcode, 0); - Py_DECREF(r); - return ret; + /* cast if necessary to desired output typecode */ + ret = PyArray_CastToType((PyArrayObject *)r, outcode, 0); + Py_DECREF(r); + return ret; } /*NUMPY_API @@ -301,192 +305,192 @@ static PyObject * PyArray_ScalarFromObject(PyObject *object) { - PyObject *ret=NULL; - if (PyArray_IsZeroDim(object)) { - return PyArray_ToScalar(PyArray_DATA(object), object); + PyObject *ret=NULL; + if (PyArray_IsZeroDim(object)) { + return PyArray_ToScalar(PyArray_DATA(object), object); + } + if (PyInt_Check(object)) { + ret = PyArrayScalar_New(Long); + if (ret == NULL) return NULL; + PyArrayScalar_VAL(ret, Long) = PyInt_AS_LONG(object); + } + else if (PyFloat_Check(object)) { + ret = PyArrayScalar_New(Double); + if (ret == NULL) return NULL; + PyArrayScalar_VAL(ret, Double) = PyFloat_AS_DOUBLE(object); + } + else if (PyComplex_Check(object)) { + ret = PyArrayScalar_New(CDouble); + if (ret == NULL) return NULL; + PyArrayScalar_VAL(ret, CDouble).real = + ((PyComplexObject *)object)->cval.real; + PyArrayScalar_VAL(ret, CDouble).imag = + ((PyComplexObject *)object)->cval.imag; + } + else if (PyLong_Check(object)) { + longlong val; + val = PyLong_AsLongLong(object); + if (val==-1 && PyErr_Occurred()) { + PyErr_Clear(); + return NULL; } - if (PyInt_Check(object)) { - ret = PyArrayScalar_New(Long); - if (ret == NULL) return NULL; - PyArrayScalar_VAL(ret, Long) = PyInt_AS_LONG(object); + ret = PyArrayScalar_New(LongLong); + if (ret == NULL) return NULL; + PyArrayScalar_VAL(ret, LongLong) = val; + } + else if (PyBool_Check(object)) { + if (object == Py_True) { + PyArrayScalar_RETURN_TRUE; } - else if (PyFloat_Check(object)) { - ret = PyArrayScalar_New(Double); - if (ret == NULL) return NULL; - PyArrayScalar_VAL(ret, Double) = PyFloat_AS_DOUBLE(object); + else { + PyArrayScalar_RETURN_FALSE; } - else if (PyComplex_Check(object)) { - ret = PyArrayScalar_New(CDouble); - if (ret == NULL) return NULL; - PyArrayScalar_VAL(ret, CDouble).real = \ - ((PyComplexObject *)object)->cval.real; - PyArrayScalar_VAL(ret, CDouble).imag = \ - ((PyComplexObject *)object)->cval.imag; - } - else if (PyLong_Check(object)) { - longlong val; - val = PyLong_AsLongLong(object); - if (val==-1 && PyErr_Occurred()) { - PyErr_Clear(); - return NULL; - } - ret = PyArrayScalar_New(LongLong); - if (ret == NULL) return NULL; - PyArrayScalar_VAL(ret, LongLong) = val; - } - else if (PyBool_Check(object)) { - if (object == Py_True) { - PyArrayScalar_RETURN_TRUE; - } - else { - PyArrayScalar_RETURN_FALSE; - } - } - return ret; + } + return ret; } static PyObject * gentype_alloc(PyTypeObject *type, Py_ssize_t nitems) { - PyObject *obj; - const size_t size = _PyObject_VAR_SIZE(type, nitems+1); + PyObject *obj; + const size_t size = _PyObject_VAR_SIZE(type, nitems+1); - obj = (PyObject *)_pya_malloc(size); - memset(obj, 0, size); - if (type->tp_itemsize == 0) - PyObject_INIT(obj, type); - else - (void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems); - return obj; + obj = (PyObject *)_pya_malloc(size); + memset(obj, 0, size); + if (type->tp_itemsize == 0) + PyObject_INIT(obj, type); + else + (void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems); + return obj; } static void gentype_dealloc(PyObject *v) { - v->ob_type->tp_free(v); + v->ob_type->tp_free(v); } static PyObject * gentype_power(PyObject *m1, PyObject *m2, PyObject *m3) { - PyObject *arr, *ret, *arg2; - char *msg="unsupported operand type(s) for ** or pow()"; + PyObject *arr, *ret, *arg2; + char *msg="unsupported operand type(s) for ** or pow()"; - if (!PyArray_IsScalar(m1,Generic)) { - if (PyArray_Check(m1)) { - ret = m1->ob_type->tp_as_number->nb_power(m1,m2, - Py_None); - } - else { - if (!PyArray_IsScalar(m2,Generic)) { - PyErr_SetString(PyExc_TypeError, msg); - return NULL; - } - arr = PyArray_FromScalar(m2, NULL); - if (arr == NULL) return NULL; - ret = arr->ob_type->tp_as_number->nb_power(m1, arr, - Py_None); - Py_DECREF(arr); - } - return ret; + if (!PyArray_IsScalar(m1,Generic)) { + if (PyArray_Check(m1)) { + ret = m1->ob_type->tp_as_number->nb_power(m1,m2, + Py_None); } - if (!PyArray_IsScalar(m2, Generic)) { - if (PyArray_Check(m2)) { - ret = m2->ob_type->tp_as_number->nb_power(m1,m2, - Py_None); - } - else { - if (!PyArray_IsScalar(m1, Generic)) { - PyErr_SetString(PyExc_TypeError, msg); - return NULL; - } - arr = PyArray_FromScalar(m1, NULL); - if (arr == NULL) return NULL; - ret = arr->ob_type->tp_as_number->nb_power(arr, m2, - Py_None); - Py_DECREF(arr); - } - return ret; + else { + if (!PyArray_IsScalar(m2,Generic)) { + PyErr_SetString(PyExc_TypeError, msg); + return NULL; + } + arr = PyArray_FromScalar(m2, NULL); + if (arr == NULL) return NULL; + ret = arr->ob_type->tp_as_number->nb_power(m1, arr, + Py_None); + Py_DECREF(arr); } - arr=arg2=NULL; - arr = PyArray_FromScalar(m1, NULL); - arg2 = PyArray_FromScalar(m2, NULL); - if (arr == NULL || arg2 == NULL) { - Py_XDECREF(arr); Py_XDECREF(arg2); return NULL; + return ret; + } + if (!PyArray_IsScalar(m2, Generic)) { + if (PyArray_Check(m2)) { + ret = m2->ob_type->tp_as_number->nb_power(m1,m2, + Py_None); } - ret = arr->ob_type->tp_as_number->nb_power(arr, arg2, Py_None); - Py_DECREF(arr); - Py_DECREF(arg2); + else { + if (!PyArray_IsScalar(m1, Generic)) { + PyErr_SetString(PyExc_TypeError, msg); + return NULL; + } + arr = PyArray_FromScalar(m1, NULL); + if (arr == NULL) return NULL; + ret = arr->ob_type->tp_as_number->nb_power(arr, m2, + Py_None); + Py_DECREF(arr); + } return ret; + } + arr=arg2=NULL; + arr = PyArray_FromScalar(m1, NULL); + arg2 = PyArray_FromScalar(m2, NULL); + if (arr == NULL || arg2 == NULL) { + Py_XDECREF(arr); Py_XDECREF(arg2); return NULL; + } + ret = arr->ob_type->tp_as_number->nb_power(arr, arg2, Py_None); + Py_DECREF(arr); + Py_DECREF(arg2); + return ret; } static PyObject * gentype_generic_method(PyObject *self, PyObject *args, PyObject *kwds, - char *str) + char *str) { - PyObject *arr, *meth, *ret; + PyObject *arr, *meth, *ret; - arr = PyArray_FromScalar(self, NULL); - if (arr == NULL) return NULL; - meth = PyObject_GetAttrString(arr, str); - if (meth == NULL) {Py_DECREF(arr); return NULL;} - if (kwds == NULL) - ret = PyObject_CallObject(meth, args); - else - ret = PyObject_Call(meth, args, kwds); - Py_DECREF(meth); - Py_DECREF(arr); - if (ret && PyArray_Check(ret)) - return PyArray_Return((PyArrayObject *)ret); - else - return ret; + arr = PyArray_FromScalar(self, NULL); + if (arr == NULL) return NULL; + meth = PyObject_GetAttrString(arr, str); + if (meth == NULL) {Py_DECREF(arr); return NULL;} + if (kwds == NULL) + ret = PyObject_CallObject(meth, args); + else + ret = PyObject_Call(meth, args, kwds); + Py_DECREF(meth); + Py_DECREF(arr); + if (ret && PyArray_Check(ret)) + return PyArray_Return((PyArrayObject *)ret); + else + return ret; } /**begin repeat + * + * #name=add, subtract, divide, remainder, divmod, lshift, rshift, and, xor, or, floor_divide, true_divide# + */ -#name=add, subtract, divide, remainder, divmod, lshift, rshift, and, xor, or, floor_divide, true_divide# -#PYNAME=Add, Subtract, Divide, Remainder, Divmod, Lshift, Rshift, And, Xor, Or, FloorDivide, TrueDivide# -*/ - static PyObject * gentype_ at name@(PyObject *m1, PyObject *m2) { - return PyArray_Type.tp_as_number->nb_ at name@(m1, m2); + return PyArray_Type.tp_as_number->nb_ at name@(m1, m2); } + /**end repeat**/ static PyObject * gentype_multiply(PyObject *m1, PyObject *m2) { - PyObject *ret=NULL; - long repeat; + PyObject *ret=NULL; + long repeat; - if (!PyArray_IsScalar(m1, Generic) && + if (!PyArray_IsScalar(m1, Generic) && ((m1->ob_type->tp_as_number == NULL) || (m1->ob_type->tp_as_number->nb_multiply == NULL))) { - /* Try to convert m2 to an int and try sequence - repeat */ - repeat = PyInt_AsLong(m2); - if (repeat == -1 && PyErr_Occurred()) return NULL; - ret = PySequence_Repeat(m1, (int) repeat); - } - else if (!PyArray_IsScalar(m2, Generic) && - ((m2->ob_type->tp_as_number == NULL) || - (m2->ob_type->tp_as_number->nb_multiply == NULL))) { - /* Try to convert m1 to an int and try sequence - repeat */ - repeat = PyInt_AsLong(m1); - if (repeat == -1 && PyErr_Occurred()) return NULL; - ret = PySequence_Repeat(m2, (int) repeat); - } - if (ret==NULL) { - PyErr_Clear(); /* no effect if not set */ - ret = PyArray_Type.tp_as_number->nb_multiply(m1, m2); - } - return ret; + /* Try to convert m2 to an int and try sequence + repeat */ + repeat = PyInt_AsLong(m2); + if (repeat == -1 && PyErr_Occurred()) return NULL; + ret = PySequence_Repeat(m1, (int) repeat); + } + else if (!PyArray_IsScalar(m2, Generic) && + ((m2->ob_type->tp_as_number == NULL) || + (m2->ob_type->tp_as_number->nb_multiply == NULL))) { + /* Try to convert m1 to an int and try sequence + repeat */ + repeat = PyInt_AsLong(m1); + if (repeat == -1 && PyErr_Occurred()) return NULL; + ret = PySequence_Repeat(m2, (int) repeat); + } + if (ret==NULL) { + PyErr_Clear(); /* no effect if not set */ + ret = PyArray_Type.tp_as_number->nb_multiply(m1, m2); + } + return ret; } /**begin repeat @@ -497,54 +501,54 @@ static PyObject * gentype_ at name@(PyObject *m1) { - PyObject *arr, *ret; + PyObject *arr, *ret; - arr = PyArray_FromScalar(m1, NULL); - if (arr == NULL) return NULL; - ret = arr->ob_type->tp_as_number->nb_ at name@(arr); - Py_DECREF(arr); - return ret; + arr = PyArray_FromScalar(m1, NULL); + if (arr == NULL) return NULL; + ret = arr->ob_type->tp_as_number->nb_ at name@(arr); + Py_DECREF(arr); + return ret; } /**end repeat**/ static int gentype_nonzero_number(PyObject *m1) { - PyObject *arr; - int ret; + PyObject *arr; + int ret; - arr = PyArray_FromScalar(m1, NULL); - if (arr == NULL) return -1; - ret = arr->ob_type->tp_as_number->nb_nonzero(arr); - Py_DECREF(arr); - return ret; + arr = PyArray_FromScalar(m1, NULL); + if (arr == NULL) return -1; + ret = arr->ob_type->tp_as_number->nb_nonzero(arr); + Py_DECREF(arr); + return ret; } static PyObject * gentype_str(PyObject *self) { - PyArrayObject *arr; - PyObject *ret; + PyArrayObject *arr; + PyObject *ret; - arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); - if (arr==NULL) return NULL; - ret = PyObject_Str((PyObject *)arr); - Py_DECREF(arr); - return ret; + arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); + if (arr==NULL) return NULL; + ret = PyObject_Str((PyObject *)arr); + Py_DECREF(arr); + return ret; } static PyObject * gentype_repr(PyObject *self) { - PyArrayObject *arr; - PyObject *ret; + PyArrayObject *arr; + PyObject *ret; - arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); - if (arr==NULL) return NULL; - ret = PyObject_Str((PyObject *)arr); - Py_DECREF(arr); - return ret; + arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); + if (arr==NULL) return NULL; + ret = PyObject_Str((PyObject *)arr); + Py_DECREF(arr); + return ret; } /**begin repeat @@ -607,20 +611,20 @@ static PyObject * @name at type_@form@(PyObject *self) { - const @type@ *dptr, *ip; - int len; - PyObject *new; - PyObject *ret; + const @type@ *dptr, *ip; + int len; + PyObject *new; + PyObject *ret; - ip = dptr = Py at Name@_AS_ at NAME@(self); - len = Py at Name@_GET_SIZE(self); - dptr += len-1; - while(len > 0 && *dptr-- == 0) len--; - new = Py at Name@_From at Name@@extra@(ip, len); - if (new == NULL) return PyString_FromString(""); - ret = Py at Name@_Type.tp_ at form@(new); - Py_DECREF(new); - return ret; + ip = dptr = Py at Name@_AS_ at NAME@(self); + len = Py at Name@_GET_SIZE(self); + dptr += len-1; + while(len > 0 && *dptr-- == 0) len--; + new = Py at Name@_From at Name@@extra@(ip, len); + if (new == NULL) return PyString_FromString(""); + ret = Py at Name@_Type.tp_ at form@(new); + Py_DECREF(new); + return ret; } /**end repeat**/ @@ -639,6 +643,8 @@ /* * float type str and repr + * + * These functions will return NULL if PyString creation fails. */ /**begin repeat * #name=float, double, longdouble# @@ -694,59 +700,59 @@ static PyObject * @char at longdoubletype_@name@(PyObject *self) { - double dval; - PyObject *obj, *ret; + double dval; + PyObject *obj, *ret; - dval = (double)(((Py at CHAR@LongDoubleScalarObject *)self)->obval)@POST@; - obj = Py at KIND@_FromDouble(dval); - ret = obj->ob_type->tp_as_number->nb_ at name@(obj); - Py_DECREF(obj); - return ret; + dval = (double)(((Py at CHAR@LongDoubleScalarObject *)self)->obval)@POST@; + obj = Py at KIND@_FromDouble(dval); + ret = obj->ob_type->tp_as_number->nb_ at name@(obj); + Py_DECREF(obj); + return ret; } /**end repeat**/ static PyNumberMethods gentype_as_number = { - (binaryfunc)gentype_add, /*nb_add*/ - (binaryfunc)gentype_subtract, /*nb_subtract*/ - (binaryfunc)gentype_multiply, /*nb_multiply*/ - (binaryfunc)gentype_divide, /*nb_divide*/ - (binaryfunc)gentype_remainder, /*nb_remainder*/ - (binaryfunc)gentype_divmod, /*nb_divmod*/ - (ternaryfunc)gentype_power, /*nb_power*/ - (unaryfunc)gentype_negative, - (unaryfunc)gentype_positive, /*nb_pos*/ - (unaryfunc)gentype_absolute, /*(unaryfunc)gentype_abs,*/ - (inquiry)gentype_nonzero_number, /*nb_nonzero*/ - (unaryfunc)gentype_invert, /*nb_invert*/ - (binaryfunc)gentype_lshift, /*nb_lshift*/ - (binaryfunc)gentype_rshift, /*nb_rshift*/ - (binaryfunc)gentype_and, /*nb_and*/ - (binaryfunc)gentype_xor, /*nb_xor*/ - (binaryfunc)gentype_or, /*nb_or*/ - 0, /*nb_coerce*/ - (unaryfunc)gentype_int, /*nb_int*/ - (unaryfunc)gentype_long, /*nb_long*/ - (unaryfunc)gentype_float, /*nb_float*/ - (unaryfunc)gentype_oct, /*nb_oct*/ - (unaryfunc)gentype_hex, /*nb_hex*/ - 0, /*inplace_add*/ - 0, /*inplace_subtract*/ - 0, /*inplace_multiply*/ - 0, /*inplace_divide*/ - 0, /*inplace_remainder*/ - 0, /*inplace_power*/ - 0, /*inplace_lshift*/ - 0, /*inplace_rshift*/ - 0, /*inplace_and*/ - 0, /*inplace_xor*/ - 0, /*inplace_or*/ - (binaryfunc)gentype_floor_divide, /*nb_floor_divide*/ - (binaryfunc)gentype_true_divide, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ + (binaryfunc)gentype_add, /*nb_add*/ + (binaryfunc)gentype_subtract, /*nb_subtract*/ + (binaryfunc)gentype_multiply, /*nb_multiply*/ + (binaryfunc)gentype_divide, /*nb_divide*/ + (binaryfunc)gentype_remainder, /*nb_remainder*/ + (binaryfunc)gentype_divmod, /*nb_divmod*/ + (ternaryfunc)gentype_power, /*nb_power*/ + (unaryfunc)gentype_negative, + (unaryfunc)gentype_positive, /*nb_pos*/ + (unaryfunc)gentype_absolute, /*(unaryfunc)gentype_abs,*/ + (inquiry)gentype_nonzero_number, /*nb_nonzero*/ + (unaryfunc)gentype_invert, /*nb_invert*/ + (binaryfunc)gentype_lshift, /*nb_lshift*/ + (binaryfunc)gentype_rshift, /*nb_rshift*/ + (binaryfunc)gentype_and, /*nb_and*/ + (binaryfunc)gentype_xor, /*nb_xor*/ + (binaryfunc)gentype_or, /*nb_or*/ + 0, /*nb_coerce*/ + (unaryfunc)gentype_int, /*nb_int*/ + (unaryfunc)gentype_long, /*nb_long*/ + (unaryfunc)gentype_float, /*nb_float*/ + (unaryfunc)gentype_oct, /*nb_oct*/ + (unaryfunc)gentype_hex, /*nb_hex*/ + 0, /*inplace_add*/ + 0, /*inplace_subtract*/ + 0, /*inplace_multiply*/ + 0, /*inplace_divide*/ + 0, /*inplace_remainder*/ + 0, /*inplace_power*/ + 0, /*inplace_lshift*/ + 0, /*inplace_rshift*/ + 0, /*inplace_and*/ + 0, /*inplace_xor*/ + 0, /*inplace_or*/ + (binaryfunc)gentype_floor_divide, /*nb_floor_divide*/ + (binaryfunc)gentype_true_divide, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ #if PY_VERSION_HEX >= 0x02050000 - (unaryfunc)NULL, /* nb_index */ + (unaryfunc)NULL, /*nb_index*/ #endif }; @@ -754,137 +760,136 @@ static PyObject * gentype_richcompare(PyObject *self, PyObject *other, int cmp_op) { + PyObject *arr, *ret; - PyObject *arr, *ret; - - arr = PyArray_FromScalar(self, NULL); - if (arr == NULL) return NULL; - ret = arr->ob_type->tp_richcompare(arr, other, cmp_op); - Py_DECREF(arr); - return ret; + arr = PyArray_FromScalar(self, NULL); + if (arr == NULL) return NULL; + ret = arr->ob_type->tp_richcompare(arr, other, cmp_op); + Py_DECREF(arr); + return ret; } static PyObject * gentype_ndim_get(PyObject *self) { - return PyInt_FromLong(0); + return PyInt_FromLong(0); } static PyObject * gentype_flags_get(PyObject *self) { - return PyArray_NewFlagsObject(NULL); + return PyArray_NewFlagsObject(NULL); } static PyObject * voidtype_flags_get(PyVoidScalarObject *self) { - PyObject *flagobj; - flagobj = PyArrayFlags_Type.tp_alloc(&PyArrayFlags_Type, 0); - if (flagobj == NULL) return NULL; - ((PyArrayFlagsObject *)flagobj)->arr = NULL; - ((PyArrayFlagsObject *)flagobj)->flags = self->flags; - return flagobj; + PyObject *flagobj; + flagobj = PyArrayFlags_Type.tp_alloc(&PyArrayFlags_Type, 0); + if (flagobj == NULL) return NULL; + ((PyArrayFlagsObject *)flagobj)->arr = NULL; + ((PyArrayFlagsObject *)flagobj)->flags = self->flags; + return flagobj; } static PyObject * voidtype_dtypedescr_get(PyVoidScalarObject *self) { - Py_INCREF(self->descr); - return (PyObject *)self->descr; + Py_INCREF(self->descr); + return (PyObject *)self->descr; } static PyObject * gentype_data_get(PyObject *self) { - return PyBuffer_FromObject(self, 0, Py_END_OF_BUFFER); + return PyBuffer_FromObject(self, 0, Py_END_OF_BUFFER); } static PyObject * gentype_itemsize_get(PyObject *self) { - PyArray_Descr *typecode; - PyObject *ret; - int elsize; + PyArray_Descr *typecode; + PyObject *ret; + int elsize; - typecode = PyArray_DescrFromScalar(self); - elsize = typecode->elsize; + typecode = PyArray_DescrFromScalar(self); + elsize = typecode->elsize; #ifndef Py_UNICODE_WIDE - if (typecode->type_num == NPY_UNICODE) { - elsize >>= 1; - } + if (typecode->type_num == NPY_UNICODE) { + elsize >>= 1; + } #endif - ret = PyInt_FromLong((long) elsize); - Py_DECREF(typecode); - return ret; + ret = PyInt_FromLong((long) elsize); + Py_DECREF(typecode); + return ret; } static PyObject * gentype_size_get(PyObject *self) { - return PyInt_FromLong(1); + return PyInt_FromLong(1); } static void gentype_struct_free(void *ptr, void *arg) { - PyArrayInterface *arrif = (PyArrayInterface *)ptr; - Py_DECREF((PyObject *)arg); - Py_XDECREF(arrif->descr); - _pya_free(arrif->shape); - _pya_free(arrif); + PyArrayInterface *arrif = (PyArrayInterface *)ptr; + Py_DECREF((PyObject *)arg); + Py_XDECREF(arrif->descr); + _pya_free(arrif->shape); + _pya_free(arrif); } static PyObject * gentype_struct_get(PyObject *self) { - PyArrayObject *arr; - PyArrayInterface *inter; + PyArrayObject *arr; + PyArrayInterface *inter; - arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); - inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface)); - inter->two = 2; - inter->nd = 0; - inter->flags = arr->flags; - inter->flags &= ~(UPDATEIFCOPY | OWNDATA); - inter->flags |= NPY_NOTSWAPPED; - inter->typekind = arr->descr->kind; - inter->itemsize = arr->descr->elsize; - inter->strides = NULL; - inter->shape = NULL; - inter->data = arr->data; - inter->descr = NULL; + arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); + inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface)); + inter->two = 2; + inter->nd = 0; + inter->flags = arr->flags; + inter->flags &= ~(UPDATEIFCOPY | OWNDATA); + inter->flags |= NPY_NOTSWAPPED; + inter->typekind = arr->descr->kind; + inter->itemsize = arr->descr->elsize; + inter->strides = NULL; + inter->shape = NULL; + inter->data = arr->data; + inter->descr = NULL; - return PyCObject_FromVoidPtrAndDesc(inter, arr, gentype_struct_free); + return PyCObject_FromVoidPtrAndDesc(inter, arr, gentype_struct_free); } static PyObject * gentype_priority_get(PyObject *self) { - return PyFloat_FromDouble(NPY_SCALAR_PRIORITY); + return PyFloat_FromDouble(NPY_SCALAR_PRIORITY); } static PyObject * gentype_shape_get(PyObject *self) { - return PyTuple_New(0); + return PyTuple_New(0); } static PyObject * gentype_interface_get(PyObject *self) { - PyArrayObject *arr; - PyObject *inter; + PyArrayObject *arr; + PyObject *inter; - arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); - if (arr == NULL) return NULL; - inter = PyObject_GetAttrString((PyObject *)arr, "__array_interface__"); - if (inter != NULL) PyDict_SetItemString(inter, "__ref", (PyObject *)arr); - Py_DECREF(arr); - return inter; + arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); + if (arr == NULL) return NULL; + inter = PyObject_GetAttrString((PyObject *)arr, "__array_interface__"); + if (inter != NULL) PyDict_SetItemString(inter, "__ref", (PyObject *)arr); + Py_DECREF(arr); + return inter; } @@ -892,194 +897,194 @@ static PyObject * gentype_typedescr_get(PyObject *self) { - return (PyObject *)PyArray_DescrFromScalar(self); + return (PyObject *)PyArray_DescrFromScalar(self); } static PyObject * gentype_base_get(PyObject *self) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } static PyArray_Descr * _realdescr_fromcomplexscalar(PyObject *self, int *typenum) { - if (PyArray_IsScalar(self, CDouble)) { - *typenum = PyArray_CDOUBLE; - return PyArray_DescrFromType(PyArray_DOUBLE); - } - if (PyArray_IsScalar(self, CFloat)) { - *typenum = PyArray_CFLOAT; - return PyArray_DescrFromType(PyArray_FLOAT); - } - if (PyArray_IsScalar(self, CLongDouble)) { - *typenum = PyArray_CLONGDOUBLE; - return PyArray_DescrFromType(PyArray_LONGDOUBLE); - } - return NULL; + if (PyArray_IsScalar(self, CDouble)) { + *typenum = PyArray_CDOUBLE; + return PyArray_DescrFromType(PyArray_DOUBLE); + } + if (PyArray_IsScalar(self, CFloat)) { + *typenum = PyArray_CFLOAT; + return PyArray_DescrFromType(PyArray_FLOAT); + } + if (PyArray_IsScalar(self, CLongDouble)) { + *typenum = PyArray_CLONGDOUBLE; + return PyArray_DescrFromType(PyArray_LONGDOUBLE); + } + return NULL; } static PyObject * gentype_real_get(PyObject *self) { - PyArray_Descr *typecode; - PyObject *ret; - int typenum; + PyArray_Descr *typecode; + PyObject *ret; + int typenum; - if (PyArray_IsScalar(self, ComplexFloating)) { - void *ptr; - typecode = _realdescr_fromcomplexscalar(self, &typenum); - ptr = scalar_value(self, NULL); - ret = PyArray_Scalar(ptr, typecode, NULL); - Py_DECREF(typecode); - return ret; - } - else if (PyArray_IsScalar(self, Object)) { - PyObject *obj = ((PyObjectScalarObject *)self)->obval; - ret = PyObject_GetAttrString(obj, "real"); - if (ret != NULL) return ret; - PyErr_Clear(); - } - Py_INCREF(self); - return (PyObject *)self; + if (PyArray_IsScalar(self, ComplexFloating)) { + void *ptr; + typecode = _realdescr_fromcomplexscalar(self, &typenum); + ptr = scalar_value(self, NULL); + ret = PyArray_Scalar(ptr, typecode, NULL); + Py_DECREF(typecode); + return ret; + } + else if (PyArray_IsScalar(self, Object)) { + PyObject *obj = ((PyObjectScalarObject *)self)->obval; + ret = PyObject_GetAttrString(obj, "real"); + if (ret != NULL) return ret; + PyErr_Clear(); + } + Py_INCREF(self); + return (PyObject *)self; } static PyObject * gentype_imag_get(PyObject *self) { - PyArray_Descr *typecode=NULL; - PyObject *ret; - int typenum; + PyArray_Descr *typecode=NULL; + PyObject *ret; + int typenum; - if (PyArray_IsScalar(self, ComplexFloating)) { - char *ptr; - typecode = _realdescr_fromcomplexscalar(self, &typenum); - ptr = (char *)scalar_value(self, NULL); - ret = PyArray_Scalar(ptr + typecode->elsize, - typecode, NULL); + if (PyArray_IsScalar(self, ComplexFloating)) { + char *ptr; + typecode = _realdescr_fromcomplexscalar(self, &typenum); + ptr = (char *)scalar_value(self, NULL); + ret = PyArray_Scalar(ptr + typecode->elsize, + typecode, NULL); + } + else if (PyArray_IsScalar(self, Object)) { + PyObject *obj = ((PyObjectScalarObject *)self)->obval; + PyArray_Descr *newtype; + ret = PyObject_GetAttrString(obj, "imag"); + if (ret == NULL) { + PyErr_Clear(); + obj = PyInt_FromLong(0); + newtype = PyArray_DescrFromType(PyArray_OBJECT); + ret = PyArray_Scalar((char *)&obj, newtype, NULL); + Py_DECREF(newtype); + Py_DECREF(obj); } - else if (PyArray_IsScalar(self, Object)) { - PyObject *obj = ((PyObjectScalarObject *)self)->obval; - PyArray_Descr *newtype; - ret = PyObject_GetAttrString(obj, "imag"); - if (ret == NULL) { - PyErr_Clear(); - obj = PyInt_FromLong(0); - newtype = PyArray_DescrFromType(PyArray_OBJECT); - ret = PyArray_Scalar((char *)&obj, newtype, NULL); - Py_DECREF(newtype); - Py_DECREF(obj); - } - } - else { - char *temp; - int elsize; - typecode = PyArray_DescrFromScalar(self); - elsize = typecode->elsize; - temp = PyDataMem_NEW(elsize); - memset(temp, '\0', elsize); - ret = PyArray_Scalar(temp, typecode, NULL); - PyDataMem_FREE(temp); - } + } + else { + char *temp; + int elsize; + typecode = PyArray_DescrFromScalar(self); + elsize = typecode->elsize; + temp = PyDataMem_NEW(elsize); + memset(temp, '\0', elsize); + ret = PyArray_Scalar(temp, typecode, NULL); + PyDataMem_FREE(temp); + } - Py_XDECREF(typecode); - return ret; + Py_XDECREF(typecode); + return ret; } static PyObject * gentype_flat_get(PyObject *self) { - PyObject *ret, *arr; + PyObject *ret, *arr; - arr = PyArray_FromScalar(self, NULL); - if (arr == NULL) return NULL; - ret = PyArray_IterNew(arr); - Py_DECREF(arr); - return ret; + arr = PyArray_FromScalar(self, NULL); + if (arr == NULL) return NULL; + ret = PyArray_IterNew(arr); + Py_DECREF(arr); + return ret; } static PyObject * gentype_transpose_get(PyObject *self) { - Py_INCREF(self); - return self; + Py_INCREF(self); + return self; } static PyGetSetDef gentype_getsets[] = { - {"ndim", - (getter)gentype_ndim_get, - (setter) 0, - "number of array dimensions"}, - {"flags", - (getter)gentype_flags_get, - (setter)0, - "integer value of flags"}, - {"shape", - (getter)gentype_shape_get, - (setter)0, - "tuple of array dimensions"}, - {"strides", - (getter)gentype_shape_get, - (setter) 0, - "tuple of bytes steps in each dimension"}, - {"data", - (getter)gentype_data_get, - (setter) 0, - "pointer to start of data"}, - {"itemsize", - (getter)gentype_itemsize_get, - (setter)0, - "length of one element in bytes"}, - {"size", - (getter)gentype_size_get, - (setter)0, - "number of elements in the gentype"}, - {"nbytes", - (getter)gentype_itemsize_get, - (setter)0, - "length of item in bytes"}, - {"base", - (getter)gentype_base_get, - (setter)0, - "base object"}, - {"dtype", - (getter)gentype_typedescr_get, - NULL, - "get array data-descriptor"}, - {"real", - (getter)gentype_real_get, - (setter)0, - "real part of scalar"}, - {"imag", - (getter)gentype_imag_get, - (setter)0, - "imaginary part of scalar"}, - {"flat", - (getter)gentype_flat_get, - (setter)0, - "a 1-d view of scalar"}, - {"T", - (getter)gentype_transpose_get, - (setter)0, - "transpose"}, - {"__array_interface__", - (getter)gentype_interface_get, - NULL, - "Array protocol: Python side"}, - {"__array_struct__", - (getter)gentype_struct_get, - NULL, - "Array protocol: struct"}, - {"__array_priority__", - (getter)gentype_priority_get, - NULL, - "Array priority."}, - {NULL, NULL, NULL, NULL} /* Sentinel */ + {"ndim", + (getter)gentype_ndim_get, + (setter) 0, + "number of array dimensions"}, + {"flags", + (getter)gentype_flags_get, + (setter)0, + "integer value of flags"}, + {"shape", + (getter)gentype_shape_get, + (setter)0, + "tuple of array dimensions"}, + {"strides", + (getter)gentype_shape_get, + (setter) 0, + "tuple of bytes steps in each dimension"}, + {"data", + (getter)gentype_data_get, + (setter) 0, + "pointer to start of data"}, + {"itemsize", + (getter)gentype_itemsize_get, + (setter)0, + "length of one element in bytes"}, + {"size", + (getter)gentype_size_get, + (setter)0, + "number of elements in the gentype"}, + {"nbytes", + (getter)gentype_itemsize_get, + (setter)0, + "length of item in bytes"}, + {"base", + (getter)gentype_base_get, + (setter)0, + "base object"}, + {"dtype", + (getter)gentype_typedescr_get, + NULL, + "get array data-descriptor"}, + {"real", + (getter)gentype_real_get, + (setter)0, + "real part of scalar"}, + {"imag", + (getter)gentype_imag_get, + (setter)0, + "imaginary part of scalar"}, + {"flat", + (getter)gentype_flat_get, + (setter)0, + "a 1-d view of scalar"}, + {"T", + (getter)gentype_transpose_get, + (setter)0, + "transpose"}, + {"__array_interface__", + (getter)gentype_interface_get, + NULL, + "Array protocol: Python side"}, + {"__array_struct__", + (getter)gentype_struct_get, + NULL, + "Array protocol: struct"}, + {"__array_priority__", + (getter)gentype_priority_get, + NULL, + "Array priority."}, + {NULL, NULL, NULL, NULL} /* Sentinel */ }; @@ -1090,16 +1095,16 @@ static PyObject * gentype_getarray(PyObject *scalar, PyObject *args) { - PyArray_Descr *outcode=NULL; - PyObject *ret; + PyArray_Descr *outcode=NULL; + PyObject *ret; - if (!PyArg_ParseTuple(args, "|O&", &PyArray_DescrConverter, - &outcode)) { - Py_XDECREF(outcode); - return NULL; - } - ret = PyArray_FromScalar(scalar, outcode); - return ret; + if (!PyArg_ParseTuple(args, "|O&", &PyArray_DescrConverter, + &outcode)) { + Py_XDECREF(outcode); + return NULL; + } + ret = PyArray_FromScalar(scalar, outcode); + return ret; } static char doc_sc_wraparray[] = "sc.__array_wrap__(obj) return scalar from array"; @@ -1107,21 +1112,21 @@ static PyObject * gentype_wraparray(PyObject *scalar, PyObject *args) { - PyObject *arr; + PyObject *arr; - if (PyTuple_Size(args) < 1) { - PyErr_SetString(PyExc_TypeError, - "only accepts 1 argument."); - return NULL; - } - arr = PyTuple_GET_ITEM(args, 0); - if (!PyArray_Check(arr)) { - PyErr_SetString(PyExc_TypeError, - "can only be called with ndarray object"); - return NULL; - } + if (PyTuple_Size(args) < 1) { + PyErr_SetString(PyExc_TypeError, + "only accepts 1 argument."); + return NULL; + } + arr = PyTuple_GET_ITEM(args, 0); + if (!PyArray_Check(arr)) { + PyErr_SetString(PyExc_TypeError, + "can only be called with ndarray object"); + return NULL; + } - return PyArray_Scalar(PyArray_DATA(arr), PyArray_DESCR(arr), arr); + return PyArray_Scalar(PyArray_DATA(arr), PyArray_DESCR(arr), arr); } @@ -1133,23 +1138,23 @@ static PyObject * gentype_ at name@(PyObject *self, PyObject *args) { - return gentype_generic_method(self, args, NULL, "@name@"); + return gentype_generic_method(self, args, NULL, "@name@"); } /**end repeat**/ static PyObject * gentype_itemset(PyObject *self, PyObject *args) { - PyErr_SetString(PyExc_ValueError, "array-scalars are immutable"); - return NULL; + PyErr_SetString(PyExc_ValueError, "array-scalars are immutable"); + return NULL; } static PyObject * gentype_squeeze(PyObject *self, PyObject *args) { - if (!PyArg_ParseTuple(args, "")) return NULL; - Py_INCREF(self); - return self; + if (!PyArg_ParseTuple(args, "")) return NULL; + Py_INCREF(self); + return self; } static Py_ssize_t @@ -1158,36 +1163,36 @@ static PyObject * gentype_byteswap(PyObject *self, PyObject *args) { - Bool inplace=FALSE; + Bool inplace=FALSE; - if (!PyArg_ParseTuple(args, "|O&", PyArray_BoolConverter, &inplace)) - return NULL; + if (!PyArg_ParseTuple(args, "|O&", PyArray_BoolConverter, &inplace)) + return NULL; - if (inplace) { - PyErr_SetString(PyExc_ValueError, - "cannot byteswap a scalar in-place"); - return NULL; - } - else { - /* get the data, copyswap it and pass it to a new Array scalar - */ - char *data; - int numbytes; - PyArray_Descr *descr; - PyObject *new; - char *newmem; + if (inplace) { + PyErr_SetString(PyExc_ValueError, + "cannot byteswap a scalar in-place"); + return NULL; + } + else { + /* get the data, copyswap it and pass it to a new Array scalar + */ + char *data; + int numbytes; + PyArray_Descr *descr; + PyObject *new; + char *newmem; - numbytes = gentype_getreadbuf(self, 0, (void **)&data); - descr = PyArray_DescrFromScalar(self); - newmem = _pya_malloc(descr->elsize); - if (newmem == NULL) {Py_DECREF(descr); return PyErr_NoMemory();} - else memcpy(newmem, data, descr->elsize); - byte_swap_vector(newmem, 1, descr->elsize); - new = PyArray_Scalar(newmem, descr, NULL); - _pya_free(newmem); - Py_DECREF(descr); - return new; - } + numbytes = gentype_getreadbuf(self, 0, (void **)&data); + descr = PyArray_DescrFromScalar(self); + newmem = _pya_malloc(descr->elsize); + if (newmem == NULL) {Py_DECREF(descr); return PyErr_NoMemory();} + else memcpy(newmem, data, descr->elsize); + byte_swap_vector(newmem, 1, descr->elsize); + new = PyArray_Scalar(newmem, descr, NULL); + _pya_free(newmem); + Py_DECREF(descr); + return new; + } } @@ -1199,198 +1204,197 @@ static PyObject * gentype_ at name@(PyObject *self, PyObject *args, PyObject *kwds) { - return gentype_generic_method(self, args, kwds, "@name@"); + return gentype_generic_method(self, args, kwds, "@name@"); } /**end repeat**/ static PyObject * voidtype_getfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds) { - PyObject *ret; + PyObject *ret; - ret = gentype_generic_method((PyObject *)self, args, kwds, "getfield"); - if (!ret) return ret; - if (PyArray_IsScalar(ret, Generic) && \ + ret = gentype_generic_method((PyObject *)self, args, kwds, "getfield"); + if (!ret) return ret; + if (PyArray_IsScalar(ret, Generic) && \ (!PyArray_IsScalar(ret, Void))) { - PyArray_Descr *new; - void *ptr; - if (!PyArray_ISNBO(self->descr->byteorder)) { - new = PyArray_DescrFromScalar(ret); - ptr = scalar_value(ret, new); - byte_swap_vector(ptr, 1, new->elsize); - Py_DECREF(new); - } + PyArray_Descr *new; + void *ptr; + if (!PyArray_ISNBO(self->descr->byteorder)) { + new = PyArray_DescrFromScalar(ret); + ptr = scalar_value(ret, new); + byte_swap_vector(ptr, 1, new->elsize); + Py_DECREF(new); } - return ret; + } + return ret; } static PyObject * gentype_setfield(PyObject *self, PyObject *args, PyObject *kwds) { - - PyErr_SetString(PyExc_TypeError, - "Can't set fields in a non-void array scalar."); - return NULL; + PyErr_SetString(PyExc_TypeError, + "Can't set fields in a non-void array scalar."); + return NULL; } static PyObject * voidtype_setfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds) { - PyArray_Descr *typecode=NULL; - int offset = 0; - PyObject *value, *src; - int mysize; - char *dptr; - static char *kwlist[] = {"value", "dtype", "offset", 0}; + PyArray_Descr *typecode=NULL; + int offset = 0; + PyObject *value, *src; + int mysize; + char *dptr; + static char *kwlist[] = {"value", "dtype", "offset", 0}; - if ((self->flags & WRITEABLE) != WRITEABLE) { - PyErr_SetString(PyExc_RuntimeError, - "Can't write to memory"); - return NULL; - } - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&|i", kwlist, - &value, - PyArray_DescrConverter, - &typecode, &offset)) { - Py_XDECREF(typecode); - return NULL; - } + if ((self->flags & WRITEABLE) != WRITEABLE) { + PyErr_SetString(PyExc_RuntimeError, + "Can't write to memory"); + return NULL; + } + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&|i", kwlist, + &value, + PyArray_DescrConverter, + &typecode, &offset)) { + Py_XDECREF(typecode); + return NULL; + } - mysize = self->ob_size; + mysize = self->ob_size; - if (offset < 0 || (offset + typecode->elsize) > mysize) { - PyErr_Format(PyExc_ValueError, - "Need 0 <= offset <= %d for requested type " \ - "but received offset = %d", - mysize-typecode->elsize, offset); - Py_DECREF(typecode); - return NULL; - } + if (offset < 0 || (offset + typecode->elsize) > mysize) { + PyErr_Format(PyExc_ValueError, + "Need 0 <= offset <= %d for requested type " \ + "but received offset = %d", + mysize-typecode->elsize, offset); + Py_DECREF(typecode); + return NULL; + } - dptr = self->obval + offset; + dptr = self->obval + offset; - if (typecode->type_num == PyArray_OBJECT) { - PyObject **temp; - Py_INCREF(value); - temp = (PyObject **)dptr; - Py_XDECREF(*temp); - memcpy(temp, &value, sizeof(PyObject *)); - Py_DECREF(typecode); - } - else { - /* Copy data from value to correct place in dptr */ - src = PyArray_FromAny(value, typecode, 0, 0, CARRAY, NULL); - if (src == NULL) return NULL; - typecode->f->copyswap(dptr, PyArray_DATA(src), - !PyArray_ISNBO(self->descr->byteorder), - src); - Py_DECREF(src); - } - Py_INCREF(Py_None); - return Py_None; + if (typecode->type_num == PyArray_OBJECT) { + PyObject **temp; + Py_INCREF(value); + temp = (PyObject **)dptr; + Py_XDECREF(*temp); + memcpy(temp, &value, sizeof(PyObject *)); + Py_DECREF(typecode); + } + else { + /* Copy data from value to correct place in dptr */ + src = PyArray_FromAny(value, typecode, 0, 0, CARRAY, NULL); + if (src == NULL) return NULL; + typecode->f->copyswap(dptr, PyArray_DATA(src), + !PyArray_ISNBO(self->descr->byteorder), + src); + Py_DECREF(src); + } + Py_INCREF(Py_None); + return Py_None; } static PyObject * gentype_reduce(PyObject *self, PyObject *args) { - PyObject *ret=NULL, *obj=NULL, *mod=NULL; - const char *buffer; - Py_ssize_t buflen; + PyObject *ret=NULL, *obj=NULL, *mod=NULL; + const char *buffer; + Py_ssize_t buflen; - /* Return a tuple of (callable object, arguments) */ + /* Return a tuple of (callable object, arguments) */ - ret = PyTuple_New(2); - if (ret == NULL) return NULL; - if (PyObject_AsReadBuffer(self, (const void **)&buffer, &buflen)<0) { - Py_DECREF(ret); return NULL; - } - mod = PyImport_ImportModule("numpy.core.multiarray"); - if (mod == NULL) return NULL; - obj = PyObject_GetAttrString(mod, "scalar"); - Py_DECREF(mod); - if (obj == NULL) return NULL; - PyTuple_SET_ITEM(ret, 0, obj); - obj = PyObject_GetAttrString((PyObject *)self, "dtype"); - if (PyArray_IsScalar(self, Object)) { - mod = ((PyObjectScalarObject *)self)->obval; - PyTuple_SET_ITEM(ret, 1, - Py_BuildValue("NO", obj, mod)); - } - else { + ret = PyTuple_New(2); + if (ret == NULL) return NULL; + if (PyObject_AsReadBuffer(self, (const void **)&buffer, &buflen)<0) { + Py_DECREF(ret); return NULL; + } + mod = PyImport_ImportModule("numpy.core.multiarray"); + if (mod == NULL) return NULL; + obj = PyObject_GetAttrString(mod, "scalar"); + Py_DECREF(mod); + if (obj == NULL) return NULL; + PyTuple_SET_ITEM(ret, 0, obj); + obj = PyObject_GetAttrString((PyObject *)self, "dtype"); + if (PyArray_IsScalar(self, Object)) { + mod = ((PyObjectScalarObject *)self)->obval; + PyTuple_SET_ITEM(ret, 1, + Py_BuildValue("NO", obj, mod)); + } + else { #ifndef Py_UNICODE_WIDE - /* We need to expand the buffer so that we always write - UCS4 to disk for pickle of unicode scalars. + /* We need to expand the buffer so that we always write + UCS4 to disk for pickle of unicode scalars. - This could be in a unicode_reduce function, but - that would require re-factoring. - */ - int alloc=0; - char *tmp; - int newlen; + This could be in a unicode_reduce function, but + that would require re-factoring. + */ + int alloc=0; + char *tmp; + int newlen; - if (PyArray_IsScalar(self, Unicode)) { - tmp = _pya_malloc(buflen*2); - if (tmp == NULL) { - Py_DECREF(ret); - return PyErr_NoMemory(); - } - alloc = 1; - newlen = PyUCS2Buffer_AsUCS4((Py_UNICODE *)buffer, - (PyArray_UCS4 *)tmp, - buflen / 2, buflen / 2); - buflen = newlen*4; - buffer = tmp; - } + if (PyArray_IsScalar(self, Unicode)) { + tmp = _pya_malloc(buflen*2); + if (tmp == NULL) { + Py_DECREF(ret); + return PyErr_NoMemory(); + } + alloc = 1; + newlen = PyUCS2Buffer_AsUCS4((Py_UNICODE *)buffer, + (PyArray_UCS4 *)tmp, + buflen / 2, buflen / 2); + buflen = newlen*4; + buffer = tmp; + } #endif - mod = PyString_FromStringAndSize(buffer, buflen); - if (mod == NULL) { - Py_DECREF(ret); + mod = PyString_FromStringAndSize(buffer, buflen); + if (mod == NULL) { + Py_DECREF(ret); #ifndef Py_UNICODE_WIDE - ret = NULL; - goto fail; + ret = NULL; + goto fail; #else - return NULL; + return NULL; #endif - } - PyTuple_SET_ITEM(ret, 1, - Py_BuildValue("NN", obj, mod)); + } + PyTuple_SET_ITEM(ret, 1, + Py_BuildValue("NN", obj, mod)); #ifndef Py_UNICODE_WIDE - fail: - if (alloc) _pya_free((char *)buffer); +fail: + if (alloc) _pya_free((char *)buffer); #endif - } - return ret; + } + return ret; } /* ignores everything */ static PyObject * gentype_setstate(PyObject *self, PyObject *args) { - Py_INCREF(Py_None); - return (Py_None); + Py_INCREF(Py_None); + return (Py_None); } static PyObject * gentype_dump(PyObject *self, PyObject *args) { - PyObject *file=NULL; - int ret; + PyObject *file=NULL; + int ret; - if (!PyArg_ParseTuple(args, "O", &file)) - return NULL; - ret = PyArray_Dump(self, file, 2); - if (ret < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + if (!PyArg_ParseTuple(args, "O", &file)) + return NULL; + ret = PyArray_Dump(self, file, 2); + if (ret < 0) return NULL; + Py_INCREF(Py_None); + return Py_None; } static PyObject * gentype_dumps(PyObject *self, PyObject *args) { - if (!PyArg_ParseTuple(args, "")) - return NULL; - return PyArray_Dumps(self, 2); + if (!PyArg_ParseTuple(args, "")) + return NULL; + return PyArray_Dumps(self, 2); } @@ -1398,146 +1402,202 @@ static PyObject * gentype_setflags(PyObject *self, PyObject *args, PyObject *kwds) { - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } /* need to fill in doc-strings for these methods on import -- copy from array docstrings */ static PyMethodDef gentype_methods[] = { - {"tolist", (PyCFunction)gentype_tolist, 1, NULL}, - {"item", (PyCFunction)gentype_item, METH_VARARGS, NULL}, - {"itemset", (PyCFunction)gentype_itemset, METH_VARARGS, NULL}, - {"tofile", (PyCFunction)gentype_tofile, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"tostring", (PyCFunction)gentype_tostring, METH_VARARGS, NULL}, - {"byteswap", (PyCFunction)gentype_byteswap,1, NULL}, - {"astype", (PyCFunction)gentype_astype, 1, NULL}, - {"getfield", (PyCFunction)gentype_getfield, - METH_VARARGS | METH_KEYWORDS, NULL}, - {"setfield", (PyCFunction)gentype_setfield, - METH_VARARGS | METH_KEYWORDS, NULL}, - {"copy", (PyCFunction)gentype_copy, 1, NULL}, - {"resize", (PyCFunction)gentype_resize, - METH_VARARGS|METH_KEYWORDS, NULL}, + {"tolist", + (PyCFunction)gentype_tolist, 1, NULL}, + {"item", + (PyCFunction)gentype_item, METH_VARARGS, NULL}, + {"itemset", + (PyCFunction)gentype_itemset, METH_VARARGS, NULL}, + {"tofile", (PyCFunction)gentype_tofile, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"tostring", + (PyCFunction)gentype_tostring, METH_VARARGS, NULL}, + {"byteswap", + (PyCFunction)gentype_byteswap,1, NULL}, + {"astype", + (PyCFunction)gentype_astype, 1, NULL}, + {"getfield", + (PyCFunction)gentype_getfield, + METH_VARARGS | METH_KEYWORDS, NULL}, + {"setfield", + (PyCFunction)gentype_setfield, + METH_VARARGS | METH_KEYWORDS, NULL}, + {"copy", + (PyCFunction)gentype_copy, 1, NULL}, + {"resize", (PyCFunction)gentype_resize, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"__array__", + (PyCFunction)gentype_getarray, 1, doc_getarray}, + {"__array_wrap__", + (PyCFunction)gentype_wraparray, 1, doc_sc_wraparray}, - {"__array__", (PyCFunction)gentype_getarray, 1, doc_getarray}, - {"__array_wrap__", (PyCFunction)gentype_wraparray, 1, doc_sc_wraparray}, + /* for the copy module */ + {"__copy__", + (PyCFunction)gentype_copy, 1, NULL}, + {"__deepcopy__", + (PyCFunction)gentype___deepcopy__, 1, NULL}, - /* for the copy module */ - {"__copy__", (PyCFunction)gentype_copy, 1, NULL}, - {"__deepcopy__", (PyCFunction)gentype___deepcopy__, 1, NULL}, + {"__reduce__", + (PyCFunction) gentype_reduce, 1, NULL}, + /* For consistency does nothing */ + {"__setstate__", + (PyCFunction) gentype_setstate, 1, NULL}, + {"dumps", + (PyCFunction) gentype_dumps, 1, NULL}, + {"dump", + (PyCFunction) gentype_dump, 1, NULL}, - {"__reduce__", (PyCFunction) gentype_reduce, 1, NULL}, - /* For consistency does nothing */ - {"__setstate__", (PyCFunction) gentype_setstate, 1, NULL}, - - {"dumps", (PyCFunction) gentype_dumps, 1, NULL}, - {"dump", (PyCFunction) gentype_dump, 1, NULL}, - - /* Methods for array */ - {"fill", (PyCFunction)gentype_fill, - METH_VARARGS, NULL}, - {"transpose", (PyCFunction)gentype_transpose, - METH_VARARGS, NULL}, - {"take", (PyCFunction)gentype_take, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"put", (PyCFunction)gentype_put, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"repeat", (PyCFunction)gentype_repeat, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"choose", (PyCFunction)gentype_choose, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"sort", (PyCFunction)gentype_sort, - METH_VARARGS, NULL}, - {"argsort", (PyCFunction)gentype_argsort, - METH_VARARGS, NULL}, - {"searchsorted", (PyCFunction)gentype_searchsorted, - METH_VARARGS, NULL}, - {"argmax", (PyCFunction)gentype_argmax, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"argmin", (PyCFunction)gentype_argmin, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"reshape", (PyCFunction)gentype_reshape, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"squeeze", (PyCFunction)gentype_squeeze, - METH_VARARGS, NULL}, - {"view", (PyCFunction)gentype_view, - METH_VARARGS, NULL}, - {"swapaxes", (PyCFunction)gentype_swapaxes, - METH_VARARGS, NULL}, - {"max", (PyCFunction)gentype_max, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"min", (PyCFunction)gentype_min, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"ptp", (PyCFunction)gentype_ptp, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"mean", (PyCFunction)gentype_mean, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"trace", (PyCFunction)gentype_trace, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"diagonal", (PyCFunction)gentype_diagonal, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"clip", (PyCFunction)gentype_clip, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"conj", (PyCFunction)gentype_conj, - METH_VARARGS, NULL}, - {"conjugate", (PyCFunction)gentype_conjugate, - METH_VARARGS, NULL}, - {"nonzero", (PyCFunction)gentype_nonzero, - METH_VARARGS, NULL}, - {"std", (PyCFunction)gentype_std, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"var", (PyCFunction)gentype_var, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"sum", (PyCFunction)gentype_sum, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"cumsum", (PyCFunction)gentype_cumsum, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"prod", (PyCFunction)gentype_prod, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"cumprod", (PyCFunction)gentype_cumprod, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"all", (PyCFunction)gentype_all, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"any", (PyCFunction)gentype_any, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"compress", (PyCFunction)gentype_compress, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"flatten", (PyCFunction)gentype_flatten, - METH_VARARGS, NULL}, - {"ravel", (PyCFunction)gentype_ravel, - METH_VARARGS, NULL}, - {"round", (PyCFunction)gentype_round, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"setflags", (PyCFunction)gentype_setflags, - METH_VARARGS|METH_KEYWORDS, NULL}, - {"newbyteorder", (PyCFunction)gentype_newbyteorder, - METH_VARARGS, NULL}, - {NULL, NULL} /* sentinel */ + /* Methods for array */ + {"fill", + (PyCFunction)gentype_fill, + METH_VARARGS, NULL}, + {"transpose", + (PyCFunction)gentype_transpose, + METH_VARARGS, NULL}, + {"take", + (PyCFunction)gentype_take, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"put", + (PyCFunction)gentype_put, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"repeat", + (PyCFunction)gentype_repeat, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"choose", + (PyCFunction)gentype_choose, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"sort", + (PyCFunction)gentype_sort, + METH_VARARGS, NULL}, + {"argsort", + (PyCFunction)gentype_argsort, + METH_VARARGS, NULL}, + {"searchsorted", + (PyCFunction)gentype_searchsorted, + METH_VARARGS, NULL}, + {"argmax", + (PyCFunction)gentype_argmax, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"argmin", + (PyCFunction)gentype_argmin, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"reshape", + (PyCFunction)gentype_reshape, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"squeeze", + (PyCFunction)gentype_squeeze, + METH_VARARGS, NULL}, + {"view", + (PyCFunction)gentype_view, + METH_VARARGS, NULL}, + {"swapaxes", + (PyCFunction)gentype_swapaxes, + METH_VARARGS, NULL}, + {"max", + (PyCFunction)gentype_max, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"min", + (PyCFunction)gentype_min, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"ptp", + (PyCFunction)gentype_ptp, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"mean", + (PyCFunction)gentype_mean, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"trace", + (PyCFunction)gentype_trace, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"diagonal", + (PyCFunction)gentype_diagonal, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"clip", + (PyCFunction)gentype_clip, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"conj", + (PyCFunction)gentype_conj, + METH_VARARGS, NULL}, + {"conjugate", + (PyCFunction)gentype_conjugate, + METH_VARARGS, NULL}, + {"nonzero", + (PyCFunction)gentype_nonzero, + METH_VARARGS, NULL}, + {"std", + (PyCFunction)gentype_std, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"var", + (PyCFunction)gentype_var, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"sum", + (PyCFunction)gentype_sum, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"cumsum", + (PyCFunction)gentype_cumsum, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"prod", + (PyCFunction)gentype_prod, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"cumprod", + (PyCFunction)gentype_cumprod, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"all", + (PyCFunction)gentype_all, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"any", + (PyCFunction)gentype_any, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"compress", + (PyCFunction)gentype_compress, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"flatten", + (PyCFunction)gentype_flatten, + METH_VARARGS, NULL}, + {"ravel", + (PyCFunction)gentype_ravel, + METH_VARARGS, NULL}, + {"round", + (PyCFunction)gentype_round, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"setflags", + (PyCFunction)gentype_setflags, + METH_VARARGS|METH_KEYWORDS, NULL}, + {"newbyteorder", + (PyCFunction)gentype_newbyteorder, + METH_VARARGS, NULL}, + {NULL, NULL} /* sentinel */ }; static PyGetSetDef voidtype_getsets[] = { - {"flags", - (getter)voidtype_flags_get, - (setter)0, - "integer value of flags"}, - {"dtype", - (getter)voidtype_dtypedescr_get, - (setter)0, - "dtype object"}, - {NULL, NULL} + {"flags", + (getter)voidtype_flags_get, + (setter)0, + "integer value of flags"}, + {"dtype", + (getter)voidtype_dtypedescr_get, + (setter)0, + "dtype object"}, + {NULL, NULL} }; static PyMethodDef voidtype_methods[] = { - {"getfield", (PyCFunction)voidtype_getfield, - METH_VARARGS | METH_KEYWORDS, NULL}, - {"setfield", (PyCFunction)voidtype_setfield, - METH_VARARGS | METH_KEYWORDS, NULL}, - {NULL, NULL} + {"getfield", + (PyCFunction)voidtype_getfield, + METH_VARARGS | METH_KEYWORDS, NULL}, + {"setfield", + (PyCFunction)voidtype_setfield, + METH_VARARGS | METH_KEYWORDS, NULL}, + {NULL, NULL} }; /************* As_mapping functions for void array scalar ************/ @@ -1545,35 +1605,35 @@ static Py_ssize_t voidtype_length(PyVoidScalarObject *self) { - if (!self->descr->names) { - return 0; - } - else { /* return the number of fields */ - return (Py_ssize_t) PyTuple_GET_SIZE(self->descr->names); - } + if (!self->descr->names) { + return 0; + } + else { /* return the number of fields */ + return (Py_ssize_t) PyTuple_GET_SIZE(self->descr->names); + } } static PyObject * voidtype_item(PyVoidScalarObject *self, Py_ssize_t n) { - intp m; - PyObject *flist=NULL, *fieldinfo; + intp m; + PyObject *flist=NULL, *fieldinfo; - if (!(PyDescr_HASFIELDS(self->descr))) { - PyErr_SetString(PyExc_IndexError, - "can't index void scalar without fields"); - return NULL; - } - flist = self->descr->names; - m = PyTuple_GET_SIZE(flist); - if (n < 0) n += m; - if (n < 0 || n >= m) { - PyErr_Format(PyExc_IndexError, "invalid index (%d)", (int) n); - return NULL; - } - fieldinfo = PyDict_GetItem(self->descr->fields, - PyTuple_GET_ITEM(flist, n)); - return voidtype_getfield(self, fieldinfo, NULL); + if (!(PyDescr_HASFIELDS(self->descr))) { + PyErr_SetString(PyExc_IndexError, + "can't index void scalar without fields"); + return NULL; + } + flist = self->descr->names; + m = PyTuple_GET_SIZE(flist); + if (n < 0) n += m; + if (n < 0 || n >= m) { + PyErr_Format(PyExc_IndexError, "invalid index (%d)", (int) n); + return NULL; + } + fieldinfo = PyDict_GetItem(self->descr->fields, + PyTuple_GET_ITEM(flist, n)); + return voidtype_getfield(self, fieldinfo, NULL); } @@ -1581,132 +1641,130 @@ static PyObject * voidtype_subscript(PyVoidScalarObject *self, PyObject *ind) { - intp n; - PyObject *fieldinfo; + intp n; + PyObject *fieldinfo; - if (!(PyDescr_HASFIELDS(self->descr))) { - PyErr_SetString(PyExc_IndexError, - "can't index void scalar without fields"); - return NULL; - } + if (!(PyDescr_HASFIELDS(self->descr))) { + PyErr_SetString(PyExc_IndexError, + "can't index void scalar without fields"); + return NULL; + } - if (PyString_Check(ind) || PyUnicode_Check(ind)) { - /* look up in fields */ - fieldinfo = PyDict_GetItem(self->descr->fields, ind); - if (!fieldinfo) goto fail; - return voidtype_getfield(self, fieldinfo, NULL); - } + if (PyString_Check(ind) || PyUnicode_Check(ind)) { + /* look up in fields */ + fieldinfo = PyDict_GetItem(self->descr->fields, ind); + if (!fieldinfo) goto fail; + return voidtype_getfield(self, fieldinfo, NULL); + } - /* try to convert it to a number */ - n = PyArray_PyIntAsIntp(ind); - if (error_converting(n)) goto fail; + /* try to convert it to a number */ + n = PyArray_PyIntAsIntp(ind); + if (error_converting(n)) goto fail; - return voidtype_item(self, (Py_ssize_t)n); + return voidtype_item(self, (Py_ssize_t)n); - fail: - PyErr_SetString(PyExc_IndexError, "invalid index"); - return NULL; - +fail: + PyErr_SetString(PyExc_IndexError, "invalid index"); + return NULL; } static int voidtype_ass_item(PyVoidScalarObject *self, Py_ssize_t n, PyObject *val) { - intp m; - PyObject *flist=NULL, *fieldinfo, *newtup; - PyObject *res; + intp m; + PyObject *flist=NULL, *fieldinfo, *newtup; + PyObject *res; - if (!(PyDescr_HASFIELDS(self->descr))) { - PyErr_SetString(PyExc_IndexError, - "can't index void scalar without fields"); - return -1; - } + if (!(PyDescr_HASFIELDS(self->descr))) { + PyErr_SetString(PyExc_IndexError, + "can't index void scalar without fields"); + return -1; + } - flist = self->descr->names; - m = PyTuple_GET_SIZE(flist); - if (n < 0) n += m; - if (n < 0 || n >= m) goto fail; - fieldinfo = PyDict_GetItem(self->descr->fields, - PyTuple_GET_ITEM(flist, n)); - newtup = Py_BuildValue("(OOO)", val, - PyTuple_GET_ITEM(fieldinfo, 0), - PyTuple_GET_ITEM(fieldinfo, 1)); - res = voidtype_setfield(self, newtup, NULL); - Py_DECREF(newtup); - if (!res) return -1; - Py_DECREF(res); - return 0; + flist = self->descr->names; + m = PyTuple_GET_SIZE(flist); + if (n < 0) n += m; + if (n < 0 || n >= m) goto fail; + fieldinfo = PyDict_GetItem(self->descr->fields, + PyTuple_GET_ITEM(flist, n)); + newtup = Py_BuildValue("(OOO)", val, + PyTuple_GET_ITEM(fieldinfo, 0), + PyTuple_GET_ITEM(fieldinfo, 1)); + res = voidtype_setfield(self, newtup, NULL); + Py_DECREF(newtup); + if (!res) return -1; + Py_DECREF(res); + return 0; - fail: - PyErr_Format(PyExc_IndexError, "invalid index (%d)", (int) n); - return -1; - +fail: + PyErr_Format(PyExc_IndexError, "invalid index (%d)", (int) n); + return -1; } static int voidtype_ass_subscript(PyVoidScalarObject *self, PyObject *ind, PyObject *val) { - intp n; - char *msg = "invalid index"; - PyObject *fieldinfo, *newtup; - PyObject *res; + intp n; + char *msg = "invalid index"; + PyObject *fieldinfo, *newtup; + PyObject *res; - if (!PyDescr_HASFIELDS(self->descr)) { - PyErr_SetString(PyExc_IndexError, - "can't index void scalar without fields"); - return -1; - } + if (!PyDescr_HASFIELDS(self->descr)) { + PyErr_SetString(PyExc_IndexError, + "can't index void scalar without fields"); + return -1; + } - if (PyString_Check(ind) || PyUnicode_Check(ind)) { - /* look up in fields */ - fieldinfo = PyDict_GetItem(self->descr->fields, ind); - if (!fieldinfo) goto fail; - newtup = Py_BuildValue("(OOO)", val, - PyTuple_GET_ITEM(fieldinfo, 0), - PyTuple_GET_ITEM(fieldinfo, 1)); - res = voidtype_setfield(self, newtup, NULL); - Py_DECREF(newtup); - if (!res) return -1; - Py_DECREF(res); - return 0; - } + if (PyString_Check(ind) || PyUnicode_Check(ind)) { + /* look up in fields */ + fieldinfo = PyDict_GetItem(self->descr->fields, ind); + if (!fieldinfo) goto fail; + newtup = Py_BuildValue("(OOO)", val, + PyTuple_GET_ITEM(fieldinfo, 0), + PyTuple_GET_ITEM(fieldinfo, 1)); + res = voidtype_setfield(self, newtup, NULL); + Py_DECREF(newtup); + if (!res) return -1; + Py_DECREF(res); + return 0; + } - /* try to convert it to a number */ - n = PyArray_PyIntAsIntp(ind); - if (error_converting(n)) goto fail; - return voidtype_ass_item(self, (Py_ssize_t)n, val); + /* try to convert it to a number */ + n = PyArray_PyIntAsIntp(ind); + if (error_converting(n)) goto fail; + return voidtype_ass_item(self, (Py_ssize_t)n, val); - fail: - PyErr_SetString(PyExc_IndexError, msg); - return -1; +fail: + PyErr_SetString(PyExc_IndexError, msg); + return -1; } static PyMappingMethods voidtype_as_mapping = { #if PY_VERSION_HEX >= 0x02050000 - (lenfunc)voidtype_length, /*mp_length*/ + (lenfunc)voidtype_length, /*mp_length*/ #else - (inquiry)voidtype_length, /*mp_length*/ + (inquiry)voidtype_length, /*mp_length*/ #endif - (binaryfunc)voidtype_subscript, /*mp_subscript*/ - (objobjargproc)voidtype_ass_subscript, /*mp_ass_subscript*/ + (binaryfunc)voidtype_subscript, /*mp_subscript*/ + (objobjargproc)voidtype_ass_subscript, /*mp_ass_subscript*/ }; static PySequenceMethods voidtype_as_sequence = { #if PY_VERSION_HEX >= 0x02050000 - (lenfunc)voidtype_length, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - (ssizeargfunc)voidtype_item, /*sq_item*/ - 0, /*sq_slice*/ - (ssizeobjargproc)voidtype_ass_item /*sq_ass_item*/ + (lenfunc)voidtype_length, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + (ssizeargfunc)voidtype_item, /*sq_item*/ + 0, /*sq_slice*/ + (ssizeobjargproc)voidtype_ass_item /*sq_ass_item*/ #else - (inquiry)voidtype_length, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - (intargfunc)voidtype_item, /*sq_item*/ - 0, /*sq_slice*/ - (intobjargproc)voidtype_ass_item /*sq_ass_item*/ + (inquiry)voidtype_length, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + (intargfunc)voidtype_item, /*sq_item*/ + 0, /*sq_slice*/ + (intobjargproc)voidtype_ass_item /*sq_ass_item*/ #endif }; @@ -1715,66 +1773,66 @@ static Py_ssize_t gentype_getreadbuf(PyObject *self, Py_ssize_t segment, void **ptrptr) { - int numbytes; - PyArray_Descr *outcode; + int numbytes; + PyArray_Descr *outcode; - if (segment != 0) { - PyErr_SetString(PyExc_SystemError, - "Accessing non-existent array segment"); - return -1; - } + if (segment != 0) { + PyErr_SetString(PyExc_SystemError, + "Accessing non-existent array segment"); + return -1; + } - outcode = PyArray_DescrFromScalar(self); - numbytes = outcode->elsize; - *ptrptr = (void *)scalar_value(self, outcode); + outcode = PyArray_DescrFromScalar(self); + numbytes = outcode->elsize; + *ptrptr = (void *)scalar_value(self, outcode); #ifndef Py_UNICODE_WIDE - if (outcode->type_num == NPY_UNICODE) { - numbytes >>= 1; - } + if (outcode->type_num == NPY_UNICODE) { + numbytes >>= 1; + } #endif - Py_DECREF(outcode); - return numbytes; + Py_DECREF(outcode); + return numbytes; } static Py_ssize_t gentype_getsegcount(PyObject *self, Py_ssize_t *lenp) { - PyArray_Descr *outcode; + PyArray_Descr *outcode; - outcode = PyArray_DescrFromScalar(self); - if (lenp) { - *lenp = outcode->elsize; + outcode = PyArray_DescrFromScalar(self); + if (lenp) { + *lenp = outcode->elsize; #ifndef Py_UNICODE_WIDE - if (outcode->type_num == NPY_UNICODE) { - *lenp >>= 1; - } + if (outcode->type_num == NPY_UNICODE) { + *lenp >>= 1; + } #endif - } - Py_DECREF(outcode); - return 1; + } + Py_DECREF(outcode); + return 1; } static Py_ssize_t gentype_getcharbuf(PyObject *self, Py_ssize_t segment, constchar **ptrptr) { - if (PyArray_IsScalar(self, String) || \ + if (PyArray_IsScalar(self, String) || \ PyArray_IsScalar(self, Unicode)) - return gentype_getreadbuf(self, segment, (void **)ptrptr); - else { - PyErr_SetString(PyExc_TypeError, - "Non-character array cannot be interpreted "\ - "as character buffer."); - return -1; - } + return gentype_getreadbuf(self, segment, (void **)ptrptr); + else { + PyErr_SetString(PyExc_TypeError, + "Non-character array cannot be interpreted "\ + "as character buffer."); + return -1; + } } static PyBufferProcs gentype_as_buffer = { - gentype_getreadbuf, /*bf_getreadbuffer*/ - NULL, /*bf_getwritebuffer*/ - gentype_getsegcount, /*bf_getsegcount*/ - gentype_getcharbuf, /*bf_getcharbuffer*/ + gentype_getreadbuf, /*bf_getreadbuffer*/ + NULL, /*bf_getwritebuffer*/ + gentype_getsegcount, /*bf_getsegcount*/ + gentype_getcharbuf, /*bf_getcharbuffer*/ }; @@ -1782,27 +1840,27 @@ #define LEAFFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES static PyTypeObject PyGenericArrType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "numpy.generic", /*tp_name*/ - sizeof(PyObject), /*tp_basicsize*/ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "numpy.generic", /*tp_name*/ + sizeof(PyObject), /*tp_basicsize*/ }; static void void_dealloc(PyVoidScalarObject *v) { - if (v->flags & OWNDATA) - PyDataMem_FREE(v->obval); - Py_XDECREF(v->descr); - Py_XDECREF(v->base); - v->ob_type->tp_free(v); + if (v->flags & OWNDATA) + PyDataMem_FREE(v->obval); + Py_XDECREF(v->descr); + Py_XDECREF(v->base); + v->ob_type->tp_free(v); } static void object_arrtype_dealloc(PyObject *v) { - Py_XDECREF(((PyObjectScalarObject *)v)->obval); - v->ob_type->tp_free(v); + Py_XDECREF(((PyObjectScalarObject *)v)->obval); + v->ob_type->tp_free(v); } /* string and unicode inherit from Python Type first and so GET_ITEM is different to get to the Python Type. @@ -1812,17 +1870,17 @@ */ #define _WORK(num) \ - if (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) { \ - PyTypeObject *sup; \ - /* We are inheriting from a Python type as well so \ - give it first dibs on conversion */ \ - sup = (PyTypeObject *)PyTuple_GET_ITEM(type->tp_bases, num); \ - robj = sup->tp_new(type, args, kwds); \ - if (robj != NULL) goto finish; \ - if (PyTuple_GET_SIZE(args)!=1) return NULL; \ - PyErr_Clear(); \ - /* now do default conversion */ \ - } + if (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) { \ + PyTypeObject *sup; \ + /* We are inheriting from a Python type as well so \ + give it first dibs on conversion */ \ + sup = (PyTypeObject *)PyTuple_GET_ITEM(type->tp_bases, num); \ + robj = sup->tp_new(type, args, kwds); \ + if (robj != NULL) goto finish; \ + if (PyTuple_GET_SIZE(args)!=1) return NULL; \ + PyErr_Clear(); \ + /* now do default conversion */ \ + } #define _WORK1 _WORK(1) #define _WORKz _WORK(0) @@ -1837,69 +1895,89 @@ static PyObject * @name at _arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *obj=NULL; - PyObject *robj; - PyObject *arr; - PyArray_Descr *typecode=NULL; - int itemsize; - void *dest, *src; + PyObject *obj = NULL; + PyObject *robj; + PyObject *arr; + PyArray_Descr *typecode = NULL; + int itemsize; + void *dest, *src; - _WORK at work@ + /* allow base-class (if any) to do conversion */ + /* If successful, this will jump to finish: */ + _WORK at work@ - if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL; + if (!PyArg_ParseTuple(args, "|O", &obj)) { + return NULL; + } + typecode = PyArray_DescrFromType(PyArray_ at TYPE@); + /* typecode is new reference and stolen by + PyArray_FromAny but not PyArray_Scalar + */ + if (obj == NULL) { +#if @default@ == 0 + char *mem = malloc(sizeof(@name@)); - typecode = PyArray_DescrFromType(PyArray_ at TYPE@); - /* - * typecode is new reference and stolen by - * PyArray_Scalar and others - */ - if (obj == NULL) { -#if @default@ == 0 - char *mem; - mem = malloc(sizeof(@name@)); - memset(mem, 0, sizeof(@name@)); - robj = PyArray_Scalar(mem, typecode, NULL); - free(mem); + memset(mem, 0, sizeof(@name@)); + robj = PyArray_Scalar(mem, typecode, NULL); + free(mem); #elif @default@ == 1 - robj = PyArray_Scalar(NULL, typecode, NULL); + robj = PyArray_Scalar(NULL, typecode, NULL); #elif @default@ == 2 - obj = Py_None; - robj = PyArray_Scalar(&obj, typecode, NULL); + obj = Py_None; + robj = PyArray_Scalar(&obj, typecode, NULL); #endif - goto finish; - } + Py_DECREF(typecode); + goto finish; + } - arr = PyArray_FromAny(obj, typecode, 0, 0, FORCECAST, NULL); - if ((arr==NULL) || (PyArray_NDIM(arr) > 0)) return arr; - robj = PyArray_Return((PyArrayObject *)arr); + arr = PyArray_FromAny(obj, typecode, 0, 0, FORCECAST, NULL); + if ((arr == NULL) || (PyArray_NDIM(arr) > 0)) { + return arr; + } + /* 0-d array */ + robj = PyArray_ToScalar(PyArray_DATA(arr), (NPY_AO *)arr); + Py_DECREF(arr); - finish: - if ((robj==NULL) || (robj->ob_type == type)) return robj; - /* Need to allocate new type and copy data-area over */ - if (type->tp_itemsize) { - itemsize = PyString_GET_SIZE(robj); - } - else itemsize = 0; - obj = type->tp_alloc(type, itemsize); - if (obj == NULL) {Py_DECREF(robj); return NULL;} - if (typecode==NULL) - typecode = PyArray_DescrFromType(PyArray_ at TYPE@); - dest = scalar_value(obj, typecode); - src = scalar_value(robj, typecode); - Py_DECREF(typecode); +finish: + /* Normal return */ + if ((robj == NULL) || (robj->ob_type == type)) { + return robj; + } + + /* This return path occurs when the requested type is not created + but another scalar object is created instead (i.e. when + the base-class does the conversion in _WORK macro) */ + + /* Need to allocate new type and copy data-area over */ + if (type->tp_itemsize) { + itemsize = PyString_GET_SIZE(robj); + } + else { + itemsize = 0; + } + obj = type->tp_alloc(type, itemsize); + if (obj == NULL) { + Py_DECREF(robj); + return NULL; + } + /* typecode will be NULL */ + typecode = PyArray_DescrFromType(PyArray_ at TYPE@); + dest = scalar_value(obj, typecode); + src = scalar_value(robj, typecode); + Py_DECREF(typecode); #if @default@ == 0 - *((npy_ at name@ *)dest) = *((npy_ at name@ *)src); -#elif @default@ == 1 - if (itemsize == 0) { - itemsize = ((PyUnicodeObject *)robj)->length << 2; - } - memcpy(dest, src, itemsize); -#elif @default@ == 2 - memcpy(dest, src, sizeof(void *)); - Py_INCREF(*((PyObject **)dest)); + *((npy_ at name@ *)dest) = *((npy_ at name@ *)src); +#elif @default@ == 1 /* unicode and strings */ + if (itemsize == 0) { /* unicode */ + itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE); + } + memcpy(dest, src, itemsize); +#elif @default@ == 2 /* Object arrays */ + memcpy(dest, src, sizeof(void *)); + Py_INCREF(*((PyObject **)dest)); #endif - Py_DECREF(robj); - return obj; + Py_DECREF(robj); + return obj; } /**end repeat**/ @@ -1912,56 +1990,56 @@ static PyObject * bool_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *obj=NULL; - PyObject *arr; + PyObject *obj=NULL; + PyObject *arr; - if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL; - if (obj == NULL) - PyArrayScalar_RETURN_FALSE; - if (obj == Py_False) - PyArrayScalar_RETURN_FALSE; - if (obj == Py_True) - PyArrayScalar_RETURN_TRUE; - arr = PyArray_FROM_OTF(obj, PyArray_BOOL, FORCECAST); - if (arr && 0 == PyArray_NDIM(arr)) { - Bool val = *((Bool *)PyArray_DATA(arr)); - Py_DECREF(arr); - PyArrayScalar_RETURN_BOOL_FROM_LONG(val); - } - return PyArray_Return((PyArrayObject *)arr); + if (!PyArg_ParseTuple(args, "|O", &obj)) return NULL; + if (obj == NULL) + PyArrayScalar_RETURN_FALSE; + if (obj == Py_False) + PyArrayScalar_RETURN_FALSE; + if (obj == Py_True) + PyArrayScalar_RETURN_TRUE; + arr = PyArray_FROM_OTF(obj, PyArray_BOOL, FORCECAST); + if (arr && 0 == PyArray_NDIM(arr)) { + Bool val = *((Bool *)PyArray_DATA(arr)); + Py_DECREF(arr); + PyArrayScalar_RETURN_BOOL_FROM_LONG(val); + } + return PyArray_Return((PyArrayObject *)arr); } static PyObject * bool_arrtype_and(PyObject *a, PyObject *b) { - if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) - PyArrayScalar_RETURN_BOOL_FROM_LONG - ((a == PyArrayScalar_True)&(b == PyArrayScalar_True)); - return PyGenericArrType_Type.tp_as_number->nb_and(a, b); + if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) + PyArrayScalar_RETURN_BOOL_FROM_LONG + ((a == PyArrayScalar_True)&(b == PyArrayScalar_True)); + return PyGenericArrType_Type.tp_as_number->nb_and(a, b); } static PyObject * bool_arrtype_or(PyObject *a, PyObject *b) { - if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) - PyArrayScalar_RETURN_BOOL_FROM_LONG - ((a == PyArrayScalar_True)|(b == PyArrayScalar_True)); - return PyGenericArrType_Type.tp_as_number->nb_or(a, b); + if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) + PyArrayScalar_RETURN_BOOL_FROM_LONG + ((a == PyArrayScalar_True)|(b == PyArrayScalar_True)); + return PyGenericArrType_Type.tp_as_number->nb_or(a, b); } static PyObject * bool_arrtype_xor(PyObject *a, PyObject *b) { - if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) - PyArrayScalar_RETURN_BOOL_FROM_LONG - ((a == PyArrayScalar_True)^(b == PyArrayScalar_True)); - return PyGenericArrType_Type.tp_as_number->nb_xor(a, b); + if (PyArray_IsScalar(a, Bool) && PyArray_IsScalar(b, Bool)) + PyArrayScalar_RETURN_BOOL_FROM_LONG + ((a == PyArrayScalar_True)^(b == PyArrayScalar_True)); + return PyGenericArrType_Type.tp_as_number->nb_xor(a, b); } static int bool_arrtype_nonzero(PyObject *a) { - return a == PyArrayScalar_True; + return a == PyArrayScalar_True; } #if PY_VERSION_HEX >= 0x02050000 @@ -1974,87 +2052,87 @@ static PyObject * @name at _index(PyObject *self) { - return @type@(PyArrayScalar_VAL(self, @Name@)); + return @type@(PyArrayScalar_VAL(self, @Name@)); } /**end repeat**/ static PyObject * bool_index(PyObject *a) { - return PyInt_FromLong(PyArrayScalar_VAL(a, Bool)); + return PyInt_FromLong(PyArrayScalar_VAL(a, Bool)); } #endif /* Arithmetic methods -- only so we can override &, |, ^. */ static PyNumberMethods bool_arrtype_as_number = { - 0, /* nb_add */ - 0, /* nb_subtract */ - 0, /* nb_multiply */ - 0, /* nb_divide */ - 0, /* nb_remainder */ - 0, /* nb_divmod */ - 0, /* nb_power */ - 0, /* nb_negative */ - 0, /* nb_positive */ - 0, /* nb_absolute */ - (inquiry)bool_arrtype_nonzero, /* nb_nonzero */ - 0, /* nb_invert */ - 0, /* nb_lshift */ - 0, /* nb_rshift */ - (binaryfunc)bool_arrtype_and, /* nb_and */ - (binaryfunc)bool_arrtype_xor, /* nb_xor */ - (binaryfunc)bool_arrtype_or, /* nb_or */ + 0, /* nb_add */ + 0, /* nb_subtract */ + 0, /* nb_multiply */ + 0, /* nb_divide */ + 0, /* nb_remainder */ + 0, /* nb_divmod */ + 0, /* nb_power */ + 0, /* nb_negative */ + 0, /* nb_positive */ + 0, /* nb_absolute */ + (inquiry)bool_arrtype_nonzero, /* nb_nonzero */ + 0, /* nb_invert */ + 0, /* nb_lshift */ + 0, /* nb_rshift */ + (binaryfunc)bool_arrtype_and, /* nb_and */ + (binaryfunc)bool_arrtype_xor, /* nb_xor */ + (binaryfunc)bool_arrtype_or, /* nb_or */ }; static PyObject * void_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *obj, *arr; - ulonglong memu=1; - PyObject *new=NULL; - char *destptr; + PyObject *obj, *arr; + ulonglong memu=1; + PyObject *new=NULL; + char *destptr; - if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; - /* For a VOID scalar first see if obj is an integer or long - and create new memory of that size (filled with 0) for the scalar - */ + if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; + /* For a VOID scalar first see if obj is an integer or long + and create new memory of that size (filled with 0) for the scalar + */ - if (PyLong_Check(obj) || PyInt_Check(obj) || \ + if (PyLong_Check(obj) || PyInt_Check(obj) || \ PyArray_IsScalar(obj, Integer) || (PyArray_Check(obj) && PyArray_NDIM(obj)==0 && \ PyArray_ISINTEGER(obj))) { - new = obj->ob_type->tp_as_number->nb_long(obj); + new = obj->ob_type->tp_as_number->nb_long(obj); + } + if (new && PyLong_Check(new)) { + PyObject *ret; + memu = PyLong_AsUnsignedLongLong(new); + Py_DECREF(new); + if (PyErr_Occurred() || (memu > MAX_INT)) { + PyErr_Clear(); + PyErr_Format(PyExc_OverflowError, + "size must be smaller than %d", + (int) MAX_INT); + return NULL; } - if (new && PyLong_Check(new)) { - PyObject *ret; - memu = PyLong_AsUnsignedLongLong(new); - Py_DECREF(new); - if (PyErr_Occurred() || (memu > MAX_INT)) { - PyErr_Clear(); - PyErr_Format(PyExc_OverflowError, - "size must be smaller than %d", - (int) MAX_INT); - return NULL; - } - destptr = PyDataMem_NEW((int) memu); - if (destptr == NULL) return PyErr_NoMemory(); - ret = type->tp_alloc(type, 0); - if (ret == NULL) { - PyDataMem_FREE(destptr); - return PyErr_NoMemory(); - } - ((PyVoidScalarObject *)ret)->obval = destptr; - ((PyVoidScalarObject *)ret)->ob_size = (int) memu; - ((PyVoidScalarObject *)ret)->descr = \ - PyArray_DescrNewFromType(PyArray_VOID); - ((PyVoidScalarObject *)ret)->descr->elsize = (int) memu; - ((PyVoidScalarObject *)ret)->flags = BEHAVED | OWNDATA; - ((PyVoidScalarObject *)ret)->base = NULL; - memset(destptr, '\0', (size_t) memu); - return ret; + destptr = PyDataMem_NEW((int) memu); + if (destptr == NULL) return PyErr_NoMemory(); + ret = type->tp_alloc(type, 0); + if (ret == NULL) { + PyDataMem_FREE(destptr); + return PyErr_NoMemory(); } + ((PyVoidScalarObject *)ret)->obval = destptr; + ((PyVoidScalarObject *)ret)->ob_size = (int) memu; + ((PyVoidScalarObject *)ret)->descr = \ + PyArray_DescrNewFromType(PyArray_VOID); + ((PyVoidScalarObject *)ret)->descr->elsize = (int) memu; + ((PyVoidScalarObject *)ret)->flags = BEHAVED | OWNDATA; + ((PyVoidScalarObject *)ret)->base = NULL; + memset(destptr, '\0', (size_t) memu); + return ret; + } - arr = PyArray_FROM_OTF(obj, PyArray_VOID, FORCECAST); - return PyArray_Return((PyArrayObject *)arr); + arr = PyArray_FROM_OTF(obj, PyArray_VOID, FORCECAST); + return PyArray_Return((PyArrayObject *)arr); } @@ -2067,7 +2145,7 @@ static long @lname at _arrtype_hash(PyObject *obj) { - return (long)(((Py at name@ScalarObject *)obj)->obval); + return (long)(((Py at name@ScalarObject *)obj)->obval); } /**end repeat**/ @@ -2078,9 +2156,9 @@ static long @lname at _arrtype_hash(PyObject *obj) { - long x = (long)(((Py at name@ScalarObject *)obj)->obval); - if (x == -1) x=-2; - return x; + long x = (long)(((Py at name@ScalarObject *)obj)->obval); + if (x == -1) x=-2; + return x; } /**end repeat**/ @@ -2088,9 +2166,9 @@ static long int_arrtype_hash(PyObject *obj) { - long x = (long)(((PyIntScalarObject *)obj)->obval); - if (x == -1) x=-2; - return x; + long x = (long)(((PyIntScalarObject *)obj)->obval); + if (x == -1) x=-2; + return x; } #endif @@ -2104,23 +2182,23 @@ static long @char at longlong_arrtype_hash(PyObject *obj) { - long y; - @char at longlong x = (((Py at Char@LongLongScalarObject *)obj)->obval); + long y; + @char at longlong x = (((Py at Char@LongLongScalarObject *)obj)->obval); - if ((x <= LONG_MAX)@ext@) { - y = (long) x; - } - else { - union Mask { - long hashvals[2]; - @char at longlong v; - } both; + if ((x <= LONG_MAX)@ext@) { + y = (long) x; + } + else { + union Mask { + long hashvals[2]; + @char at longlong v; + } both; - both.v = x; - y = both.hashvals[0] + (1000003)*both.hashvals[1]; - } - if (y == -1) y = -2; - return y; + both.v = x; + y = both.hashvals[0] + (1000003)*both.hashvals[1]; + } + if (y == -1) y = -2; + return y; } #endif /**end repeat**/ @@ -2129,9 +2207,9 @@ static long ulonglong_arrtype_hash(PyObject *obj) { - long x = (long)(((PyULongLongScalarObject *)obj)->obval); - if (x == -1) x=-2; - return x; + long x = (long)(((PyULongLongScalarObject *)obj)->obval); + if (x == -1) x=-2; + return x; } #endif @@ -2145,230 +2223,230 @@ static long @lname at _arrtype_hash(PyObject *obj) { - return _Py_HashDouble((double) ((Py at name@ScalarObject *)obj)->obval); + return _Py_HashDouble((double) ((Py at name@ScalarObject *)obj)->obval); } /* borrowed from complex_hash */ static long c at lname@_arrtype_hash(PyObject *obj) { - long hashreal, hashimag, combined; - hashreal = _Py_HashDouble((double) \ - (((PyC at name@ScalarObject *)obj)->obval).real); + long hashreal, hashimag, combined; + hashreal = _Py_HashDouble((double) \ + (((PyC at name@ScalarObject *)obj)->obval).real); - if (hashreal == -1) return -1; - hashimag = _Py_HashDouble((double) \ - (((PyC at name@ScalarObject *)obj)->obval).imag); - if (hashimag == -1) return -1; + if (hashreal == -1) return -1; + hashimag = _Py_HashDouble((double) \ + (((PyC at name@ScalarObject *)obj)->obval).imag); + if (hashimag == -1) return -1; - combined = hashreal + 1000003 * hashimag; - if (combined == -1) combined = -2; - return combined; + combined = hashreal + 1000003 * hashimag; + if (combined == -1) combined = -2; + return combined; } /**end repeat**/ static long object_arrtype_hash(PyObject *obj) { - return PyObject_Hash(((PyObjectScalarObject *)obj)->obval); + return PyObject_Hash(((PyObjectScalarObject *)obj)->obval); } /* just hash the pointer */ static long void_arrtype_hash(PyObject *obj) { - return _Py_HashPointer((void *)(((PyVoidScalarObject *)obj)->obval)); + return _Py_HashPointer((void *)(((PyVoidScalarObject *)obj)->obval)); } /*object arrtype getattro and setattro */ static PyObject * object_arrtype_getattro(PyObjectScalarObject *obj, PyObject *attr) { - PyObject *res; + PyObject *res; - /* first look in object and then hand off to generic type */ + /* first look in object and then hand off to generic type */ - res = PyObject_GenericGetAttr(obj->obval, attr); - if (res) return res; - PyErr_Clear(); - return PyObject_GenericGetAttr((PyObject *)obj, attr); + res = PyObject_GenericGetAttr(obj->obval, attr); + if (res) return res; + PyErr_Clear(); + return PyObject_GenericGetAttr((PyObject *)obj, attr); } static int object_arrtype_setattro(PyObjectScalarObject *obj, PyObject *attr, PyObject *val) { - int res; - /* first look in object and then hand off to generic type */ + int res; + /* first look in object and then hand off to generic type */ - res = PyObject_GenericSetAttr(obj->obval, attr, val); - if (res >= 0) return res; - PyErr_Clear(); - return PyObject_GenericSetAttr((PyObject *)obj, attr, val); + res = PyObject_GenericSetAttr(obj->obval, attr, val); + if (res >= 0) return res; + PyErr_Clear(); + return PyObject_GenericSetAttr((PyObject *)obj, attr, val); } static PyObject * object_arrtype_concat(PyObjectScalarObject *self, PyObject *other) { - return PySequence_Concat(self->obval, other); + return PySequence_Concat(self->obval, other); } static Py_ssize_t object_arrtype_length(PyObjectScalarObject *self) { - return PyObject_Length(self->obval); + return PyObject_Length(self->obval); } static PyObject * object_arrtype_repeat(PyObjectScalarObject *self, Py_ssize_t count) { - return PySequence_Repeat(self->obval, count); + return PySequence_Repeat(self->obval, count); } static PyObject * object_arrtype_subscript(PyObjectScalarObject *self, PyObject *key) { - return PyObject_GetItem(self->obval, key); + return PyObject_GetItem(self->obval, key); } static int object_arrtype_ass_subscript(PyObjectScalarObject *self, PyObject *key, PyObject *value) { - return PyObject_SetItem(self->obval, key, value); + return PyObject_SetItem(self->obval, key, value); } static int object_arrtype_contains(PyObjectScalarObject *self, PyObject *ob) { - return PySequence_Contains(self->obval, ob); + return PySequence_Contains(self->obval, ob); } static PyObject * object_arrtype_inplace_concat(PyObjectScalarObject *self, PyObject *o) { - return PySequence_InPlaceConcat(self->obval, o); + return PySequence_InPlaceConcat(self->obval, o); } static PyObject * object_arrtype_inplace_repeat(PyObjectScalarObject *self, Py_ssize_t count) { - return PySequence_InPlaceRepeat(self->obval, count); + return PySequence_InPlaceRepeat(self->obval, count); } static PySequenceMethods object_arrtype_as_sequence = { #if PY_VERSION_HEX >= 0x02050000 - (lenfunc)object_arrtype_length, /*sq_length*/ - (binaryfunc)object_arrtype_concat, /*sq_concat*/ - (ssizeargfunc)object_arrtype_repeat, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /* sq_ass_item */ - 0, /* sq_ass_slice */ - (objobjproc)object_arrtype_contains, /* sq_contains */ - (binaryfunc)object_arrtype_inplace_concat, /* sq_inplace_concat */ - (ssizeargfunc)object_arrtype_inplace_repeat, /* sq_inplace_repeat */ + (lenfunc)object_arrtype_length, /*sq_length*/ + (binaryfunc)object_arrtype_concat, /*sq_concat*/ + (ssizeargfunc)object_arrtype_repeat, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /* sq_ass_item */ + 0, /* sq_ass_slice */ + (objobjproc)object_arrtype_contains, /* sq_contains */ + (binaryfunc)object_arrtype_inplace_concat, /* sq_inplace_concat */ + (ssizeargfunc)object_arrtype_inplace_repeat, /* sq_inplace_repeat */ #else - (inquiry)object_arrtype_length, /*sq_length*/ - (binaryfunc)object_arrtype_concat, /*sq_concat*/ - (intargfunc)object_arrtype_repeat, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /* sq_ass_item */ - 0, /* sq_ass_slice */ - (objobjproc)object_arrtype_contains, /* sq_contains */ - (binaryfunc)object_arrtype_inplace_concat, /* sq_inplace_concat */ - (intargfunc)object_arrtype_inplace_repeat, /* sq_inplace_repeat */ + (inquiry)object_arrtype_length, /*sq_length*/ + (binaryfunc)object_arrtype_concat, /*sq_concat*/ + (intargfunc)object_arrtype_repeat, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /* sq_ass_item */ + 0, /* sq_ass_slice */ + (objobjproc)object_arrtype_contains, /* sq_contains */ + (binaryfunc)object_arrtype_inplace_concat, /* sq_inplace_concat */ + (intargfunc)object_arrtype_inplace_repeat, /* sq_inplace_repeat */ #endif }; static PyMappingMethods object_arrtype_as_mapping = { #if PY_VERSION_HEX >= 0x02050000 - (lenfunc)object_arrtype_length, - (binaryfunc)object_arrtype_subscript, - (objobjargproc)object_arrtype_ass_subscript, + (lenfunc)object_arrtype_length, + (binaryfunc)object_arrtype_subscript, + (objobjargproc)object_arrtype_ass_subscript, #else - (inquiry)object_arrtype_length, - (binaryfunc)object_arrtype_subscript, - (objobjargproc)object_arrtype_ass_subscript, + (inquiry)object_arrtype_length, + (binaryfunc)object_arrtype_subscript, + (objobjargproc)object_arrtype_ass_subscript, #endif }; static Py_ssize_t object_arrtype_getsegcount(PyObjectScalarObject *self, Py_ssize_t *lenp) { - Py_ssize_t newlen; - int cnt; - PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer; + Py_ssize_t newlen; + int cnt; + PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer; - if (pb == NULL || \ + if (pb == NULL || \ pb->bf_getsegcount == NULL || \ (cnt = (*pb->bf_getsegcount)(self->obval, &newlen)) != 1) - return 0; + return 0; - if (lenp) - *lenp = newlen; + if (lenp) + *lenp = newlen; - return cnt; + return cnt; } static Py_ssize_t object_arrtype_getreadbuf(PyObjectScalarObject *self, Py_ssize_t segment, void **ptrptr) { - PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer; + PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer; - if (pb == NULL || \ + if (pb == NULL || \ pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL) { - PyErr_SetString(PyExc_TypeError, - "expected a readable buffer object"); - return -1; - } + PyErr_SetString(PyExc_TypeError, + "expected a readable buffer object"); + return -1; + } - return (*pb->bf_getreadbuffer)(self->obval, segment, ptrptr); + return (*pb->bf_getreadbuffer)(self->obval, segment, ptrptr); } static Py_ssize_t object_arrtype_getwritebuf(PyObjectScalarObject *self, Py_ssize_t segment, void **ptrptr) { - PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer; + PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer; - if (pb == NULL || \ + if (pb == NULL || \ pb->bf_getwritebuffer == NULL || pb->bf_getsegcount == NULL) { - PyErr_SetString(PyExc_TypeError, - "expected a writeable buffer object"); - return -1; - } + PyErr_SetString(PyExc_TypeError, + "expected a writeable buffer object"); + return -1; + } - return (*pb->bf_getwritebuffer)(self->obval, segment, ptrptr); + return (*pb->bf_getwritebuffer)(self->obval, segment, ptrptr); } static Py_ssize_t object_arrtype_getcharbuf(PyObjectScalarObject *self, Py_ssize_t segment, constchar **ptrptr) { - PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer; + PyBufferProcs *pb = self->obval->ob_type->tp_as_buffer; - if (pb == NULL || \ + if (pb == NULL || \ pb->bf_getcharbuffer == NULL || pb->bf_getsegcount == NULL) { - PyErr_SetString(PyExc_TypeError, - "expected a character buffer object"); - return -1; - } + PyErr_SetString(PyExc_TypeError, + "expected a character buffer object"); + return -1; + } - return (*pb->bf_getcharbuffer)(self->obval, segment, ptrptr); + return (*pb->bf_getcharbuffer)(self->obval, segment, ptrptr); } static PyBufferProcs object_arrtype_as_buffer = { #if PY_VERSION_HEX >= 0x02050000 - (readbufferproc)object_arrtype_getreadbuf, - (writebufferproc)object_arrtype_getwritebuf, - (segcountproc)object_arrtype_getsegcount, - (charbufferproc)object_arrtype_getcharbuf, + (readbufferproc)object_arrtype_getreadbuf, + (writebufferproc)object_arrtype_getwritebuf, + (segcountproc)object_arrtype_getsegcount, + (charbufferproc)object_arrtype_getcharbuf, #else - (getreadbufferproc)object_arrtype_getreadbuf, - (getwritebufferproc)object_arrtype_getwritebuf, - (getsegcountproc)object_arrtype_getsegcount, - (getcharbufferproc)object_arrtype_getcharbuf, + (getreadbufferproc)object_arrtype_getreadbuf, + (getwritebufferproc)object_arrtype_getwritebuf, + (getsegcountproc)object_arrtype_getsegcount, + (getcharbufferproc)object_arrtype_getcharbuf, #endif }; @@ -2379,27 +2457,27 @@ } static PyTypeObject PyObjectArrType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "numpy.object_", /*tp_name*/ - sizeof(PyObjectScalarObject), /*tp_basicsize*/ - 0, /* tp_itemsize */ - (destructor)object_arrtype_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - &object_arrtype_as_sequence, /* tp_as_sequence */ - &object_arrtype_as_mapping, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)object_arrtype_call, /* tp_call */ - 0, /* tp_str */ - (getattrofunc)object_arrtype_getattro, /* tp_getattro */ - (setattrofunc)object_arrtype_setattro, /* tp_setattro */ - &object_arrtype_as_buffer, /* tp_as_buffer */ - 0, /* tp_flags */ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "numpy.object_", /*tp_name*/ + sizeof(PyObjectScalarObject), /*tp_basicsize*/ + 0, /* tp_itemsize */ + (destructor)object_arrtype_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + &object_arrtype_as_sequence, /* tp_as_sequence */ + &object_arrtype_as_mapping, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)object_arrtype_call, /* tp_call */ + 0, /* tp_str */ + (getattrofunc)object_arrtype_getattro, /* tp_getattro */ + (setattrofunc)object_arrtype_setattro, /* tp_setattro */ + &object_arrtype_as_buffer, /* tp_as_buffer */ + 0, /* tp_flags */ }; @@ -2412,54 +2490,54 @@ static PyObject * gen_arrtype_subscript(PyObject *self, PyObject *key) { - /* Only [...], [...,], [, ...], - is allowed for indexing a scalar + /* Only [...], [...,], [, ...], + is allowed for indexing a scalar - These return a new N-d array with a copy of - the data where N is the number of None's in . + These return a new N-d array with a copy of + the data where N is the number of None's in . - */ - PyObject *res, *ret; - int N; + */ + PyObject *res, *ret; + int N; - if (key == Py_Ellipsis || key == Py_None || - PyTuple_Check(key)) { - res = PyArray_FromScalar(self, NULL); - } - else { - PyErr_SetString(PyExc_IndexError, - "invalid index to scalar variable."); - return NULL; - } + if (key == Py_Ellipsis || key == Py_None || + PyTuple_Check(key)) { + res = PyArray_FromScalar(self, NULL); + } + else { + PyErr_SetString(PyExc_IndexError, + "invalid index to scalar variable."); + return NULL; + } - if (key == Py_Ellipsis) - return res; + if (key == Py_Ellipsis) + return res; - if (key == Py_None) { - ret = add_new_axes_0d((PyArrayObject *)res, 1); - Py_DECREF(res); - return ret; - } - /* Must be a Tuple */ + if (key == Py_None) { + ret = add_new_axes_0d((PyArrayObject *)res, 1); + Py_DECREF(res); + return ret; + } + /* Must be a Tuple */ - N = count_new_axes_0d(key); - if (N < 0) return NULL; - ret = add_new_axes_0d((PyArrayObject *)res, N); - Py_DECREF(res); - return ret; + N = count_new_axes_0d(key); + if (N < 0) return NULL; + ret = add_new_axes_0d((PyArrayObject *)res, N); + Py_DECREF(res); + return ret; } /**begin repeat -#name=bool, string, unicode, void# -#NAME=Bool, String, Unicode, Void# -#ex=_,_,_,# -*/ + * #name=bool, string, unicode, void# + * #NAME=Bool, String, Unicode, Void# + * #ex=_,_,_,# + */ static PyTypeObject Py at NAME@ArrType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "numpy. at name@@ex@", /*tp_name*/ - sizeof(Py at NAME@ScalarObject), /*tp_basicsize*/ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "numpy. at name@@ex@", /*tp_name*/ + sizeof(Py at NAME@ScalarObject), /*tp_basicsize*/ }; /**end repeat**/ @@ -2486,10 +2564,10 @@ #define _THIS_SIZE "256" #endif static PyTypeObject Py at NAME@ArrType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "numpy. at name@" _THIS_SIZE, /*tp_name*/ - sizeof(Py at NAME@ScalarObject), /*tp_basicsize*/ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "numpy. at name@" _THIS_SIZE, /*tp_name*/ + sizeof(Py at NAME@ScalarObject), /*tp_basicsize*/ }; #undef _THIS_SIZE @@ -2497,9 +2575,9 @@ static PyMappingMethods gentype_as_mapping = { - NULL, - (binaryfunc)gen_arrtype_subscript, - NULL + NULL, + (binaryfunc)gen_arrtype_subscript, + NULL }; @@ -2531,28 +2609,28 @@ #define _THIS_SIZE1 "512" #endif static PyTypeObject Py at NAME@ArrType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "numpy. at name@" _THIS_SIZE1, /*tp_name*/ - sizeof(Py at NAME@ScalarObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "Composed of two " _THIS_SIZE2 " bit floats", /* tp_doc */ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "numpy. at name@" _THIS_SIZE1, /*tp_name*/ + sizeof(Py at NAME@ScalarObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + 0, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Composed of two " _THIS_SIZE2 " bit floats", /* tp_doc */ }; #undef _THIS_SIZE1 #undef _THIS_SIZE2 @@ -2567,178 +2645,178 @@ static void initialize_numeric_types(void) { - PyGenericArrType_Type.tp_dealloc = (destructor)gentype_dealloc; - PyGenericArrType_Type.tp_as_number = &gentype_as_number; - PyGenericArrType_Type.tp_as_buffer = &gentype_as_buffer; - PyGenericArrType_Type.tp_as_mapping = &gentype_as_mapping; - PyGenericArrType_Type.tp_flags = BASEFLAGS; - PyGenericArrType_Type.tp_methods = gentype_methods; - PyGenericArrType_Type.tp_getset = gentype_getsets; - PyGenericArrType_Type.tp_new = NULL; - PyGenericArrType_Type.tp_alloc = gentype_alloc; - PyGenericArrType_Type.tp_free = _pya_free; - PyGenericArrType_Type.tp_repr = gentype_repr; - PyGenericArrType_Type.tp_str = gentype_str; - PyGenericArrType_Type.tp_richcompare = gentype_richcompare; + PyGenericArrType_Type.tp_dealloc = (destructor)gentype_dealloc; + PyGenericArrType_Type.tp_as_number = &gentype_as_number; + PyGenericArrType_Type.tp_as_buffer = &gentype_as_buffer; + PyGenericArrType_Type.tp_as_mapping = &gentype_as_mapping; + PyGenericArrType_Type.tp_flags = BASEFLAGS; + PyGenericArrType_Type.tp_methods = gentype_methods; + PyGenericArrType_Type.tp_getset = gentype_getsets; + PyGenericArrType_Type.tp_new = NULL; + PyGenericArrType_Type.tp_alloc = gentype_alloc; + PyGenericArrType_Type.tp_free = _pya_free; + PyGenericArrType_Type.tp_repr = gentype_repr; + PyGenericArrType_Type.tp_str = gentype_str; + PyGenericArrType_Type.tp_richcompare = gentype_richcompare; - PyBoolArrType_Type.tp_as_number = &bool_arrtype_as_number; + PyBoolArrType_Type.tp_as_number = &bool_arrtype_as_number; #if PY_VERSION_HEX >= 0x02050000 - /* need to add dummy versions with filled-in nb_index - in-order for PyType_Ready to fill in .__index__() method - */ - /**begin repeat + /* need to add dummy versions with filled-in nb_index + in-order for PyType_Ready to fill in .__index__() method + */ + /**begin repeat #name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong# #NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong# - */ - Py at NAME@ArrType_Type.tp_as_number = &@name at _arrtype_as_number; - Py at NAME@ArrType_Type.tp_as_number->nb_index = (unaryfunc)@name at _index; + */ + Py at NAME@ArrType_Type.tp_as_number = &@name at _arrtype_as_number; + Py at NAME@ArrType_Type.tp_as_number->nb_index = (unaryfunc)@name at _index; - /**end repeat**/ - PyBoolArrType_Type.tp_as_number->nb_index = (unaryfunc)bool_index; + /**end repeat**/ + PyBoolArrType_Type.tp_as_number->nb_index = (unaryfunc)bool_index; #endif - PyStringArrType_Type.tp_alloc = NULL; - PyStringArrType_Type.tp_free = NULL; + PyStringArrType_Type.tp_alloc = NULL; + PyStringArrType_Type.tp_free = NULL; - PyStringArrType_Type.tp_repr = stringtype_repr; - PyStringArrType_Type.tp_str = stringtype_str; + PyStringArrType_Type.tp_repr = stringtype_repr; + PyStringArrType_Type.tp_str = stringtype_str; - PyUnicodeArrType_Type.tp_repr = unicodetype_repr; - PyUnicodeArrType_Type.tp_str = unicodetype_str; + PyUnicodeArrType_Type.tp_repr = unicodetype_repr; + PyUnicodeArrType_Type.tp_str = unicodetype_str; - PyVoidArrType_Type.tp_methods = voidtype_methods; - PyVoidArrType_Type.tp_getset = voidtype_getsets; - PyVoidArrType_Type.tp_as_mapping = &voidtype_as_mapping; - PyVoidArrType_Type.tp_as_sequence = &voidtype_as_sequence; + PyVoidArrType_Type.tp_methods = voidtype_methods; + PyVoidArrType_Type.tp_getset = voidtype_getsets; + PyVoidArrType_Type.tp_as_mapping = &voidtype_as_mapping; + PyVoidArrType_Type.tp_as_sequence = &voidtype_as_sequence; - /**begin repeat + /**begin repeat #NAME=Number, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character# - */ - Py at NAME@ArrType_Type.tp_flags = BASEFLAGS; - /**end repeat**/ + */ + Py at NAME@ArrType_Type.tp_flags = BASEFLAGS; + /**end repeat**/ - /**begin repeat + /**begin repeat #name=bool, byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, void, object# #NAME=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, String, Unicode, Void, Object# - */ - Py at NAME@ArrType_Type.tp_flags = BASEFLAGS; - Py at NAME@ArrType_Type.tp_new = @name at _arrtype_new; - Py at NAME@ArrType_Type.tp_richcompare = gentype_richcompare; - /**end repeat**/ + */ + Py at NAME@ArrType_Type.tp_flags = BASEFLAGS; + Py at NAME@ArrType_Type.tp_new = @name at _arrtype_new; + Py at NAME@ArrType_Type.tp_richcompare = gentype_richcompare; + /**end repeat**/ - /**begin repeat + /**begin repeat #name=bool, byte, short, ubyte, ushort, uint, ulong, ulonglong, float, longdouble, cfloat, clongdouble, void, object# #NAME=Bool, Byte, Short, UByte, UShort, UInt, ULong, ULongLong, Float, LongDouble, CFloat, CLongDouble, Void, Object# - */ - Py at NAME@ArrType_Type.tp_hash = @name at _arrtype_hash; - /**end repeat**/ + */ + Py at NAME@ArrType_Type.tp_hash = @name at _arrtype_hash; + /**end repeat**/ #if SIZEOF_INT != SIZEOF_LONG - /* We won't be inheriting from Python Int type. */ - PyIntArrType_Type.tp_hash = int_arrtype_hash; + /* We won't be inheriting from Python Int type. */ + PyIntArrType_Type.tp_hash = int_arrtype_hash; #endif #if SIZEOF_LONG != SIZEOF_LONGLONG - /* We won't be inheriting from Python Int type. */ - PyLongLongArrType_Type.tp_hash = longlong_arrtype_hash; + /* We won't be inheriting from Python Int type. */ + PyLongLongArrType_Type.tp_hash = longlong_arrtype_hash; #endif - /**begin repeat - *#name = repr, str# - */ - PyFloatArrType_Type.tp_ at name@ = floattype_ at name@; - PyCFloatArrType_Type.tp_ at name@ = cfloattype_ at name@; + /**begin repeat + *#name = repr, str# + */ + PyFloatArrType_Type.tp_ at name@ = floattype_ at name@; + PyCFloatArrType_Type.tp_ at name@ = cfloattype_ at name@; - PyDoubleArrType_Type.tp_ at name@ = doubletype_ at name@; - PyCDoubleArrType_Type.tp_ at name@ = cdoubletype_ at name@; - /**end repeat**/ + PyDoubleArrType_Type.tp_ at name@ = doubletype_ at name@; + PyCDoubleArrType_Type.tp_ at name@ = cdoubletype_ at name@; + /**end repeat**/ - /* These need to be coded specially because getitem does not - return a normal Python type - */ - PyLongDoubleArrType_Type.tp_as_number = &longdoubletype_as_number; - PyCLongDoubleArrType_Type.tp_as_number = &clongdoubletype_as_number; + /* These need to be coded specially because getitem does not + return a normal Python type + */ + PyLongDoubleArrType_Type.tp_as_number = &longdoubletype_as_number; + PyCLongDoubleArrType_Type.tp_as_number = &clongdoubletype_as_number; - /**begin repeat -#name=int, long, hex, oct, float, repr, str# -#kind=tp_as_number->nb*5, tp*2# - */ - PyLongDoubleArrType_Type. at kind@_ at name@ = longdoubletype_ at name@; - PyCLongDoubleArrType_Type. at kind@_ at name@ = clongdoubletype_ at name@; - /**end repeat**/ + /**begin repeat + * #name=int, long, hex, oct, float, repr, str# + * #kind=tp_as_number->nb*5, tp*2# + */ + PyLongDoubleArrType_Type. at kind@_ at name@ = longdoubletype_ at name@; + PyCLongDoubleArrType_Type. at kind@_ at name@ = clongdoubletype_ at name@; + /**end repeat**/ - PyStringArrType_Type.tp_itemsize = sizeof(char); - PyVoidArrType_Type.tp_dealloc = (destructor) void_dealloc; + PyStringArrType_Type.tp_itemsize = sizeof(char); + PyVoidArrType_Type.tp_dealloc = (destructor) void_dealloc; - PyArrayIter_Type.tp_iter = PyObject_SelfIter; - PyArrayMapIter_Type.tp_iter = PyObject_SelfIter; + PyArrayIter_Type.tp_iter = PyObject_SelfIter; + PyArrayMapIter_Type.tp_iter = PyObject_SelfIter; } /* the order of this table is important */ static PyTypeObject *typeobjects[] = { - &PyBoolArrType_Type, - &PyByteArrType_Type, - &PyUByteArrType_Type, - &PyShortArrType_Type, - &PyUShortArrType_Type, - &PyIntArrType_Type, - &PyUIntArrType_Type, - &PyLongArrType_Type, - &PyULongArrType_Type, - &PyLongLongArrType_Type, - &PyULongLongArrType_Type, - &PyFloatArrType_Type, - &PyDoubleArrType_Type, - &PyLongDoubleArrType_Type, - &PyCFloatArrType_Type, - &PyCDoubleArrType_Type, - &PyCLongDoubleArrType_Type, - &PyObjectArrType_Type, - &PyStringArrType_Type, - &PyUnicodeArrType_Type, - &PyVoidArrType_Type + &PyBoolArrType_Type, + &PyByteArrType_Type, + &PyUByteArrType_Type, + &PyShortArrType_Type, + &PyUShortArrType_Type, + &PyIntArrType_Type, + &PyUIntArrType_Type, + &PyLongArrType_Type, + &PyULongArrType_Type, + &PyLongLongArrType_Type, + &PyULongLongArrType_Type, + &PyFloatArrType_Type, + &PyDoubleArrType_Type, + &PyLongDoubleArrType_Type, + &PyCFloatArrType_Type, + &PyCDoubleArrType_Type, + &PyCLongDoubleArrType_Type, + &PyObjectArrType_Type, + &PyStringArrType_Type, + &PyUnicodeArrType_Type, + &PyVoidArrType_Type }; static int _typenum_fromtypeobj(PyObject *type, int user) { - int typenum, i; + int typenum, i; - typenum = PyArray_NOTYPE; - i = 0; - while(i < PyArray_NTYPES) { - if (type == (PyObject *)typeobjects[i]) { - typenum = i; - break; - } - i++; + typenum = PyArray_NOTYPE; + i = 0; + while(i < PyArray_NTYPES) { + if (type == (PyObject *)typeobjects[i]) { + typenum = i; + break; } + i++; + } - if (!user) return typenum; + if (!user) return typenum; - /* Search any registered types */ - i = 0; - while (i < PyArray_NUMUSERTYPES) { - if (type == (PyObject *)(userdescrs[i]->typeobj)) { - typenum = i + PyArray_USERDEF; - break; - } - i++; + /* Search any registered types */ + i = 0; + while (i < PyArray_NUMUSERTYPES) { + if (type == (PyObject *)(userdescrs[i]->typeobj)) { + typenum = i + PyArray_USERDEF; + break; } - return typenum; + i++; + } + return typenum; } static PyArray_Descr * _descr_from_subtype(PyObject *type) { - PyObject *mro; - mro = ((PyTypeObject *)type)->tp_mro; - if (PyTuple_GET_SIZE(mro) < 2) { - return PyArray_DescrFromType(PyArray_OBJECT); - } - return PyArray_DescrFromTypeObject(PyTuple_GET_ITEM(mro, 1)); + PyObject *mro; + mro = ((PyTypeObject *)type)->tp_mro; + if (PyTuple_GET_SIZE(mro) < 2) { + return PyArray_DescrFromType(PyArray_OBJECT); + } + return PyArray_DescrFromTypeObject(PyTuple_GET_ITEM(mro, 1)); } /*New reference */ @@ -2747,64 +2825,64 @@ static PyArray_Descr * PyArray_DescrFromTypeObject(PyObject *type) { - int typenum; - PyArray_Descr *new, *conv=NULL; + int typenum; + PyArray_Descr *new, *conv=NULL; - /* if it's a builtin type, then use the typenumber */ - typenum = _typenum_fromtypeobj(type,1); - if (typenum != PyArray_NOTYPE) { - new = PyArray_DescrFromType(typenum); - return new; - } + /* if it's a builtin type, then use the typenumber */ + typenum = _typenum_fromtypeobj(type,1); + if (typenum != PyArray_NOTYPE) { + new = PyArray_DescrFromType(typenum); + return new; + } - /* Check the generic types */ - if ((type == (PyObject *) &PyNumberArrType_Type) || \ + /* Check the generic types */ + if ((type == (PyObject *) &PyNumberArrType_Type) || \ (type == (PyObject *) &PyInexactArrType_Type) || \ (type == (PyObject *) &PyFloatingArrType_Type)) - typenum = PyArray_DOUBLE; - else if (type == (PyObject *)&PyComplexFloatingArrType_Type) - typenum = PyArray_CDOUBLE; - else if ((type == (PyObject *)&PyIntegerArrType_Type) || \ - (type == (PyObject *)&PySignedIntegerArrType_Type)) - typenum = PyArray_LONG; - else if (type == (PyObject *) &PyUnsignedIntegerArrType_Type) - typenum = PyArray_ULONG; - else if (type == (PyObject *) &PyCharacterArrType_Type) - typenum = PyArray_STRING; - else if ((type == (PyObject *) &PyGenericArrType_Type) || \ - (type == (PyObject *) &PyFlexibleArrType_Type)) - typenum = PyArray_VOID; + typenum = PyArray_DOUBLE; + else if (type == (PyObject *)&PyComplexFloatingArrType_Type) + typenum = PyArray_CDOUBLE; + else if ((type == (PyObject *)&PyIntegerArrType_Type) || \ + (type == (PyObject *)&PySignedIntegerArrType_Type)) + typenum = PyArray_LONG; + else if (type == (PyObject *) &PyUnsignedIntegerArrType_Type) + typenum = PyArray_ULONG; + else if (type == (PyObject *) &PyCharacterArrType_Type) + typenum = PyArray_STRING; + else if ((type == (PyObject *) &PyGenericArrType_Type) || \ + (type == (PyObject *) &PyFlexibleArrType_Type)) + typenum = PyArray_VOID; - if (typenum != PyArray_NOTYPE) { - return PyArray_DescrFromType(typenum); - } + if (typenum != PyArray_NOTYPE) { + return PyArray_DescrFromType(typenum); + } - /* Otherwise --- type is a sub-type of an array scalar - not corresponding to a registered data-type object. - */ + /* Otherwise --- type is a sub-type of an array scalar + not corresponding to a registered data-type object. + */ - /* Do special thing for VOID sub-types - */ - if (PyType_IsSubtype((PyTypeObject *)type, &PyVoidArrType_Type)) { - new = PyArray_DescrNewFromType(PyArray_VOID); + /* Do special thing for VOID sub-types + */ + if (PyType_IsSubtype((PyTypeObject *)type, &PyVoidArrType_Type)) { + new = PyArray_DescrNewFromType(PyArray_VOID); - conv = _arraydescr_fromobj(type); - if (conv) { - new->fields = conv->fields; - Py_INCREF(new->fields); - new->names = conv->names; - Py_INCREF(new->names); - new->elsize = conv->elsize; - new->subarray = conv->subarray; - conv->subarray = NULL; - Py_DECREF(conv); - } - Py_XDECREF(new->typeobj); - new->typeobj = (PyTypeObject *)type; - Py_INCREF(type); - return new; + conv = _arraydescr_fromobj(type); + if (conv) { + new->fields = conv->fields; + Py_INCREF(new->fields); + new->names = conv->names; + Py_INCREF(new->names); + new->elsize = conv->elsize; + new->subarray = conv->subarray; + conv->subarray = NULL; + Py_DECREF(conv); } - return _descr_from_subtype(type); + Py_XDECREF(new->typeobj); + new->typeobj = (PyTypeObject *)type; + Py_INCREF(type); + return new; + } + return _descr_from_subtype(type); } /*NUMPY_API @@ -2813,24 +2891,24 @@ static PyObject * PyArray_FieldNames(PyObject *fields) { - PyObject *tup; - PyObject *ret; - PyObject *_numpy_internal; + PyObject *tup; + PyObject *ret; + PyObject *_numpy_internal; - if (!PyDict_Check(fields)) { - PyErr_SetString(PyExc_TypeError, - "Fields must be a dictionary"); - return NULL; - } - _numpy_internal = PyImport_ImportModule("numpy.core._internal"); - if (_numpy_internal == NULL) return NULL; - tup = PyObject_CallMethod(_numpy_internal, "_makenames_list", "O", fields); - Py_DECREF(_numpy_internal); - if (tup == NULL) return NULL; - ret = PyTuple_GET_ITEM(tup, 0); - ret = PySequence_Tuple(ret); - Py_DECREF(tup); - return ret; + if (!PyDict_Check(fields)) { + PyErr_SetString(PyExc_TypeError, + "Fields must be a dictionary"); + return NULL; + } + _numpy_internal = PyImport_ImportModule("numpy.core._internal"); + if (_numpy_internal == NULL) return NULL; + tup = PyObject_CallMethod(_numpy_internal, "_makenames_list", "O", fields); + Py_DECREF(_numpy_internal); + if (tup == NULL) return NULL; + ret = PyTuple_GET_ITEM(tup, 0); + ret = PySequence_Tuple(ret); + Py_DECREF(tup); + return ret; } /* New reference */ @@ -2840,41 +2918,41 @@ static PyArray_Descr * PyArray_DescrFromScalar(PyObject *sc) { - int type_num; - PyArray_Descr *descr; + int type_num; + PyArray_Descr *descr; - if (PyArray_IsScalar(sc, Void)) { - descr = ((PyVoidScalarObject *)sc)->descr; - Py_INCREF(descr); - return descr; - } - descr = PyArray_DescrFromTypeObject((PyObject *)sc->ob_type); - if (descr->elsize == 0) { - PyArray_DESCR_REPLACE(descr); - type_num = descr->type_num; - if (type_num == PyArray_STRING) - descr->elsize = PyString_GET_SIZE(sc); - else if (type_num == PyArray_UNICODE) { - descr->elsize = PyUnicode_GET_DATA_SIZE(sc); + if (PyArray_IsScalar(sc, Void)) { + descr = ((PyVoidScalarObject *)sc)->descr; + Py_INCREF(descr); + return descr; + } + descr = PyArray_DescrFromTypeObject((PyObject *)sc->ob_type); + if (descr->elsize == 0) { + PyArray_DESCR_REPLACE(descr); + type_num = descr->type_num; + if (type_num == PyArray_STRING) + descr->elsize = PyString_GET_SIZE(sc); + else if (type_num == PyArray_UNICODE) { + descr->elsize = PyUnicode_GET_DATA_SIZE(sc); #ifndef Py_UNICODE_WIDE - descr->elsize <<= 1; + descr->elsize <<= 1; #endif - } - else { - descr->elsize = - ((PyVoidScalarObject *)sc)->ob_size; - descr->fields = PyObject_GetAttrString(sc, "fields"); - if (!descr->fields || !PyDict_Check(descr->fields) || - (descr->fields == Py_None)) { - Py_XDECREF(descr->fields); - descr->fields = NULL; - } - if (descr->fields) - descr->names = PyArray_FieldNames(descr->fields); - PyErr_Clear(); - } } - return descr; + else { + descr->elsize = + ((PyVoidScalarObject *)sc)->ob_size; + descr->fields = PyObject_GetAttrString(sc, "fields"); + if (!descr->fields || !PyDict_Check(descr->fields) || + (descr->fields == Py_None)) { + Py_XDECREF(descr->fields); + descr->fields = NULL; + } + if (descr->fields) + descr->names = PyArray_FieldNames(descr->fields); + PyErr_Clear(); + } + } + return descr; } /* New reference */ @@ -2884,13 +2962,13 @@ static PyObject * PyArray_TypeObjectFromType(int type) { - PyArray_Descr *descr; - PyObject *obj; + PyArray_Descr *descr; + PyObject *obj; - descr = PyArray_DescrFromType(type); - if (descr == NULL) return NULL; - obj = (PyObject *)descr->typeobj; - Py_XINCREF(obj); - Py_DECREF(descr); - return obj; + descr = PyArray_DescrFromType(type); + if (descr == NULL) return NULL; + obj = (PyObject *)descr->typeobj; + Py_XINCREF(obj); + Py_DECREF(descr); + return obj; } From numpy-svn at scipy.org Sun Jul 20 01:49:35 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 00:49:35 -0500 (CDT) Subject: [Numpy-svn] r5461 - in branches/1.1.x/numpy: core distutils random Message-ID: <20080720054935.296D139C10E@scipy.org> Author: charris Date: 2008-07-20 00:49:31 -0500 (Sun, 20 Jul 2008) New Revision: 5461 Modified: branches/1.1.x/numpy/core/setup.py branches/1.1.x/numpy/distutils/misc_util.py branches/1.1.x/numpy/random/setup.py Log: Backport r5452 build fixes. Modified: branches/1.1.x/numpy/core/setup.py =================================================================== --- branches/1.1.x/numpy/core/setup.py 2008-07-20 02:16:34 UTC (rev 5460) +++ branches/1.1.x/numpy/core/setup.py 2008-07-20 05:49:31 UTC (rev 5461) @@ -65,7 +65,10 @@ header_dir = 'include/numpy' # this is relative to config.path_in_package def generate_config_h(ext, build_dir): - target = join(build_dir,'config.h') + target = join(build_dir,header_dir,'config.h') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) if newer(__file__,target): config_cmd = config.get_config_cmd() log.info('Generating %s',target) @@ -159,7 +162,10 @@ def generate_numpyconfig_h(ext, build_dir): """Depends on config.h: generate_config_h has to be called before !""" - target = join(build_dir,'numpyconfig.h') + target = join(build_dir,header_dir,'numpyconfig.h') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) if newer(__file__,target): config_cmd = config.get_config_cmd() log.info('Generating %s',target) @@ -198,7 +204,7 @@ try: m = __import__(module_name) log.info('executing %s', script) - h_file, c_file, doc_file = m.generate_api(build_dir) + h_file, c_file, doc_file = m.generate_api(os.path.join(build_dir, header_dir)) finally: del sys.path[0] config.add_data_files((header_dir, h_file), @@ -210,7 +216,10 @@ generate_ufunc_api = generate_api_func('generate_ufunc_api') def generate_umath_c(ext,build_dir): - target = join(build_dir,'__umath_generated.c') + target = join(build_dir,header_dir,'__umath_generated.c') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) script = generate_umath_py if newer(script,target): f = open(target,'w') Modified: branches/1.1.x/numpy/distutils/misc_util.py =================================================================== --- branches/1.1.x/numpy/distutils/misc_util.py 2008-07-20 02:16:34 UTC (rev 5460) +++ branches/1.1.x/numpy/distutils/misc_util.py 2008-07-20 05:49:31 UTC (rev 5461) @@ -114,9 +114,20 @@ def get_mathlibs(path=None): """Return the MATHLIB line from numpyconfig.h """ - if path is None: - path = os.path.join(get_numpy_include_dirs()[0], 'numpy') - config_file = os.path.join(path,'numpyconfig.h') + if path is not None: + config_file = os.path.join(path,'numpyconfig.h') + else: + # Look for the file in each of the numpy include directories. + dirs = get_numpy_include_dirs() + for path in dirs: + fn = os.path.join(path,'numpyconfig.h') + if os.path.exists(fn): + config_file = fn + break + else: + raise DistutilsError('numpyconfig.h not found in numpy include ' + 'dirs %r' % (dirs,)) + fid = open(config_file) mathlibs = [] s = '#define MATHLIB' Modified: branches/1.1.x/numpy/random/setup.py =================================================================== --- branches/1.1.x/numpy/random/setup.py 2008-07-20 02:16:34 UTC (rev 5460) +++ branches/1.1.x/numpy/random/setup.py 2008-07-20 05:49:31 UTC (rev 5461) @@ -6,11 +6,7 @@ def generate_libraries(ext, build_dir): config_cmd = config.get_config_cmd() - if top_path is None: - libs = get_mathlibs() - else: - path = join(split(build_dir)[0],'core') - libs = get_mathlibs(path) + libs = get_mathlibs() tc = testcode_wincrypt() if config_cmd.try_run(tc): libs.append('Advapi32') From numpy-svn at scipy.org Sun Jul 20 02:02:21 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 01:02:21 -0500 (CDT) Subject: [Numpy-svn] r5462 - branches/1.1.x/numpy/testing Message-ID: <20080720060221.5C71639C10E@scipy.org> Author: charris Date: 2008-07-20 01:02:19 -0500 (Sun, 20 Jul 2008) New Revision: 5462 Modified: branches/1.1.x/numpy/testing/numpytest.py Log: Add verbose keyword to test for compatibility with trunk. Modified: branches/1.1.x/numpy/testing/numpytest.py =================================================================== --- branches/1.1.x/numpy/testing/numpytest.py 2008-07-20 05:49:31 UTC (rev 5461) +++ branches/1.1.x/numpy/testing/numpytest.py 2008-07-20 06:02:19 UTC (rev 5462) @@ -527,7 +527,7 @@ all_tests = unittest.TestSuite(suite_list) return all_tests - def test(self, level=1, verbosity=1, all=True, sys_argv=[], + def test(self, level=1, verbosity=1, verbose=0, all=True, sys_argv=[], testcase_pattern='.*'): """Run Numpy module test suite with level and verbosity. @@ -560,6 +560,10 @@ (with names having prefixes 'check_' or 'bench_'); each of these methods are called when running unit tests. """ + # add verbose keyword and make it an alias for verbosity + # so that buildbots using newer test framework work. + verbosity = max(verbosity, verbose) + if level is None: # Do nothing. return From numpy-svn at scipy.org Sun Jul 20 02:41:01 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 01:41:01 -0500 (CDT) Subject: [Numpy-svn] r5463 - branches/1.1.x/numpy/ma/tests Message-ID: <20080720064101.7C02739C16F@scipy.org> Author: charris Date: 2008-07-20 01:40:59 -0500 (Sun, 20 Jul 2008) New Revision: 5463 Modified: branches/1.1.x/numpy/ma/tests/test_mrecords.py Log: Backport part of r5446 to fudge test of exotic type failing on SPARC. Modified: branches/1.1.x/numpy/ma/tests/test_mrecords.py =================================================================== --- branches/1.1.x/numpy/ma/tests/test_mrecords.py 2008-07-20 06:02:19 UTC (rev 5462) +++ branches/1.1.x/numpy/ma/tests/test_mrecords.py 2008-07-20 06:40:59 UTC (rev 5463) @@ -279,7 +279,7 @@ # def test_exotic_formats(self): "Test that 'exotic' formats are processed properly" - easy = mrecarray(1, dtype=[('i',int), ('s','|S3'), ('f',float)]) + easy = mrecarray(1, dtype=[('i',int), ('s','|S8'), ('f',float)]) easy[0] = masked easy.filled(1) assert_equal(easy.filled(1).item(), (1,'1',1.)) From numpy-svn at scipy.org Sun Jul 20 03:07:55 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 02:07:55 -0500 (CDT) Subject: [Numpy-svn] r5464 - in branches/1.1.x/numpy: core distutils random Message-ID: <20080720070755.2B2A7C7C024@scipy.org> Author: charris Date: 2008-07-20 02:07:51 -0500 (Sun, 20 Jul 2008) New Revision: 5464 Modified: branches/1.1.x/numpy/core/setup.py branches/1.1.x/numpy/distutils/misc_util.py branches/1.1.x/numpy/random/setup.py Log: Revert r5461, it seems to cause obscure problems Modified: branches/1.1.x/numpy/core/setup.py =================================================================== --- branches/1.1.x/numpy/core/setup.py 2008-07-20 06:40:59 UTC (rev 5463) +++ branches/1.1.x/numpy/core/setup.py 2008-07-20 07:07:51 UTC (rev 5464) @@ -65,10 +65,7 @@ header_dir = 'include/numpy' # this is relative to config.path_in_package def generate_config_h(ext, build_dir): - target = join(build_dir,header_dir,'config.h') - dir = os.path.dirname(target) - if not os.path.exists(dir): - os.makedirs(dir) + target = join(build_dir,'config.h') if newer(__file__,target): config_cmd = config.get_config_cmd() log.info('Generating %s',target) @@ -162,10 +159,7 @@ def generate_numpyconfig_h(ext, build_dir): """Depends on config.h: generate_config_h has to be called before !""" - target = join(build_dir,header_dir,'numpyconfig.h') - dir = os.path.dirname(target) - if not os.path.exists(dir): - os.makedirs(dir) + target = join(build_dir,'numpyconfig.h') if newer(__file__,target): config_cmd = config.get_config_cmd() log.info('Generating %s',target) @@ -204,7 +198,7 @@ try: m = __import__(module_name) log.info('executing %s', script) - h_file, c_file, doc_file = m.generate_api(os.path.join(build_dir, header_dir)) + h_file, c_file, doc_file = m.generate_api(build_dir) finally: del sys.path[0] config.add_data_files((header_dir, h_file), @@ -216,10 +210,7 @@ generate_ufunc_api = generate_api_func('generate_ufunc_api') def generate_umath_c(ext,build_dir): - target = join(build_dir,header_dir,'__umath_generated.c') - dir = os.path.dirname(target) - if not os.path.exists(dir): - os.makedirs(dir) + target = join(build_dir,'__umath_generated.c') script = generate_umath_py if newer(script,target): f = open(target,'w') Modified: branches/1.1.x/numpy/distutils/misc_util.py =================================================================== --- branches/1.1.x/numpy/distutils/misc_util.py 2008-07-20 06:40:59 UTC (rev 5463) +++ branches/1.1.x/numpy/distutils/misc_util.py 2008-07-20 07:07:51 UTC (rev 5464) @@ -114,20 +114,9 @@ def get_mathlibs(path=None): """Return the MATHLIB line from numpyconfig.h """ - if path is not None: - config_file = os.path.join(path,'numpyconfig.h') - else: - # Look for the file in each of the numpy include directories. - dirs = get_numpy_include_dirs() - for path in dirs: - fn = os.path.join(path,'numpyconfig.h') - if os.path.exists(fn): - config_file = fn - break - else: - raise DistutilsError('numpyconfig.h not found in numpy include ' - 'dirs %r' % (dirs,)) - + if path is None: + path = os.path.join(get_numpy_include_dirs()[0], 'numpy') + config_file = os.path.join(path,'numpyconfig.h') fid = open(config_file) mathlibs = [] s = '#define MATHLIB' Modified: branches/1.1.x/numpy/random/setup.py =================================================================== --- branches/1.1.x/numpy/random/setup.py 2008-07-20 06:40:59 UTC (rev 5463) +++ branches/1.1.x/numpy/random/setup.py 2008-07-20 07:07:51 UTC (rev 5464) @@ -6,7 +6,11 @@ def generate_libraries(ext, build_dir): config_cmd = config.get_config_cmd() - libs = get_mathlibs() + if top_path is None: + libs = get_mathlibs() + else: + path = join(split(build_dir)[0],'core') + libs = get_mathlibs(path) tc = testcode_wincrypt() if config_cmd.try_run(tc): libs.append('Advapi32') From numpy-svn at scipy.org Sun Jul 20 03:27:22 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 02:27:22 -0500 (CDT) Subject: [Numpy-svn] r5465 - trunk/numpy/lib Message-ID: <20080720072722.AD64C39C10E@scipy.org> Author: rkern Date: 2008-07-20 02:27:21 -0500 (Sun, 20 Jul 2008) New Revision: 5465 Modified: trunk/numpy/lib/format.py Log: BUG: Allow longs as well as ints to satisfy Win64. Modified: trunk/numpy/lib/format.py =================================================================== --- trunk/numpy/lib/format.py 2008-07-20 07:07:51 UTC (rev 5464) +++ trunk/numpy/lib/format.py 2008-07-20 07:27:21 UTC (rev 5465) @@ -244,7 +244,7 @@ # Sanity-check the values. if (not isinstance(d['shape'], tuple) or - not numpy.all([isinstance(x, int) for x in d['shape']])): + not numpy.all([isinstance(x, (int,long)) for x in d['shape']])): msg = "shape is not valid: %r" raise ValueError(msg % (d['shape'],)) if not isinstance(d['fortran_order'], bool): From numpy-svn at scipy.org Sun Jul 20 03:46:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 02:46:30 -0500 (CDT) Subject: [Numpy-svn] r5466 - trunk/numpy/ma/tests Message-ID: <20080720074630.1C66039C226@scipy.org> Author: charris Date: 2008-07-20 02:46:28 -0500 (Sun, 20 Jul 2008) New Revision: 5466 Modified: trunk/numpy/ma/tests/test_mrecords.py Log: Testing SPARC alignment. Modified: trunk/numpy/ma/tests/test_mrecords.py =================================================================== --- trunk/numpy/ma/tests/test_mrecords.py 2008-07-20 07:27:21 UTC (rev 5465) +++ trunk/numpy/ma/tests/test_mrecords.py 2008-07-20 07:46:28 UTC (rev 5466) @@ -327,6 +327,8 @@ # def test_exotic_formats(self): "Test that 'exotic' formats are processed properly" + print "float alignment: ", np.dtype(np.float).alignment + print "int alignment: ", np.dtype(np.int).alignment easy = mrecarray(1, dtype=[('i',int), ('s','|S8'), ('f',float)]) easy[0] = masked assert_equal(easy.filled(1).item(), (1,'1',1.)) From numpy-svn at scipy.org Sun Jul 20 04:29:26 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 03:29:26 -0500 (CDT) Subject: [Numpy-svn] r5467 - trunk/numpy/ma/tests Message-ID: <20080720082926.66E2039C342@scipy.org> Author: charris Date: 2008-07-20 03:29:21 -0500 (Sun, 20 Jul 2008) New Revision: 5467 Modified: trunk/numpy/ma/tests/test_mrecords.py Log: Undo test of SPARC alignment. Modified: trunk/numpy/ma/tests/test_mrecords.py =================================================================== --- trunk/numpy/ma/tests/test_mrecords.py 2008-07-20 07:46:28 UTC (rev 5466) +++ trunk/numpy/ma/tests/test_mrecords.py 2008-07-20 08:29:21 UTC (rev 5467) @@ -327,8 +327,6 @@ # def test_exotic_formats(self): "Test that 'exotic' formats are processed properly" - print "float alignment: ", np.dtype(np.float).alignment - print "int alignment: ", np.dtype(np.int).alignment easy = mrecarray(1, dtype=[('i',int), ('s','|S8'), ('f',float)]) easy[0] = masked assert_equal(easy.filled(1).item(), (1,'1',1.)) From numpy-svn at scipy.org Sun Jul 20 08:05:48 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 07:05:48 -0500 (CDT) Subject: [Numpy-svn] r5468 - trunk/numpy/core/tests Message-ID: <20080720120548.9D4CC39C63D@scipy.org> Author: ptvirtan Date: 2008-07-20 07:05:41 -0500 (Sun, 20 Jul 2008) New Revision: 5468 Modified: trunk/numpy/core/tests/test_umath.py Log: Fix errors in C99 tests. Skip tests failing on some platforms. Modified: trunk/numpy/core/tests/test_umath.py =================================================================== --- trunk/numpy/core/tests/test_umath.py 2008-07-20 08:29:21 UTC (rev 5467) +++ trunk/numpy/core/tests/test_umath.py 2008-07-20 12:05:41 UTC (rev 5468) @@ -280,17 +280,16 @@ ((-0., 0.), (-inf, pi), 'divide'), ((+0., 0.), (-inf, 0.), 'divide'), ((1., inf), (inf, pi/2), ''), - ((1., nan), (nan, nan), ''), + ((1., nan), (nan, nan), 'invalid-optional'), ((-inf, 1.), (inf, pi), ''), ((inf, 1.), (inf, 0.), ''), ((-inf, inf), (inf, 3*pi/4), ''), ((inf, inf), (inf, pi/4), ''), ((inf, nan), (inf, nan), ''), ((-inf, nan), (inf, nan), ''), - ((nan, 0.), (nan, nan), ''), - ((nan, 1.), (nan, nan), ''), + ((nan, 1.), (nan, nan), 'invalid-optional'), ((nan, inf), (inf, nan), ''), - ((+nan, nan), (nan, nan), ''), + ((+nan, nan), (nan, nan), 'XXX'), # raises 'invalid' on some platfs ]: yield self._check, np.log, p, v, e @@ -300,7 +299,7 @@ ((0., 0.), (0.,0.), ''), ((1., inf), (inf,inf), 'XXX invalid'), # now (inf, nan) ((nan, inf), (inf,inf), 'XXX'), # now (nan, nan) - ((-inf, 1.), (0.,inf), ''), + ((-inf, 1.), (0.,inf), 'XXX'), # (-0., inf) on Mac OSX ((inf, 1.), (inf,0.), ''), ((-inf,nan), (nan, -inf), 'XXX'), # could also be +inf. raises 'invalid' on Sparc64 ((inf, nan), (inf, nan), ''), @@ -374,7 +373,7 @@ ((inf, nan), (0, nan), 'XXX'), # now: (nan, nan) ((nan, 1.), (nan, nan), 'invalid-optional'), ((nan, inf), (+0, pi/2), 'XXX'), # now: (nan, nan) - ((nan, nan), (nan, nan), ''), + ((nan, nan), (nan, nan), 'XXX'), # raises 'invalid' on some platfs ]: yield self._check, np.arctanh, p, v, e From numpy-svn at scipy.org Sun Jul 20 12:28:12 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 11:28:12 -0500 (CDT) Subject: [Numpy-svn] r5469 - trunk/numpy/lib Message-ID: <20080720162812.C2DECC7C00B@scipy.org> Author: ptvirtan Date: 2008-07-20 11:28:04 -0500 (Sun, 20 Jul 2008) New Revision: 5469 Modified: trunk/numpy/lib/utils.py Log: Add a pydoc import in lookfor; missed in the import refactoring. Modified: trunk/numpy/lib/utils.py =================================================================== --- trunk/numpy/lib/utils.py 2008-07-20 12:05:41 UTC (rev 5468) +++ trunk/numpy/lib/utils.py 2008-07-20 16:28:04 UTC (rev 5469) @@ -502,6 +502,8 @@ Re-generate the docstring cache """ + import pydoc + # Cache cache = _lookfor_generate_cache(module, import_modules, regenerate) From numpy-svn at scipy.org Sun Jul 20 15:24:58 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 14:24:58 -0500 (CDT) Subject: [Numpy-svn] r5470 - in trunk/numpy/core: src tests Message-ID: <20080720192458.17F1E39C23D@scipy.org> Author: charris Date: 2008-07-20 14:24:54 -0500 (Sun, 20 Jul 2008) New Revision: 5470 Modified: trunk/numpy/core/src/umathmodule.c.src trunk/numpy/core/tests/test_regression.py Log: Fix ticket #794. Modified: trunk/numpy/core/src/umathmodule.c.src =================================================================== --- trunk/numpy/core/src/umathmodule.c.src 2008-07-20 16:28:04 UTC (rev 5469) +++ trunk/numpy/core/src/umathmodule.c.src 2008-07-20 19:24:54 UTC (rev 5470) @@ -1683,9 +1683,15 @@ #define BOOL_negative BOOL_logical_not -#define _SIGN1(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) +#define _SIGN1(x) (isnan((x)) ? NAN : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) #define _SIGN2(x) ((x) == 0 ? 0 : 1) -#define _SIGNC(x) (((x).real > 0) ? 1 : ((x).real < 0 ? -1 : ((x).imag > 0 ? 1 : ((x).imag < 0) ? -1 : 0))) +#define _SIGNC(x) (isnan((x.real)) ? NAN : \ + isnan((x.imag)) ? NAN : \ + ((x).real > 0) ? 1 : \ + ((x).real < 0 ? -1 : \ + ((x).imag > 0 ? 1 : \ + ((x).imag < 0) ? -1 : 0))) + /**begin repeat #TYPE=BYTE,SHORT,INT,LONG,LONGLONG,FLOAT,DOUBLE,LONGDOUBLE,UBYTE,USHORT,UINT,ULONG,ULONGLONG# #typ=byte,short,int,long,longlong,float,double,longdouble,ubyte,ushort,uint,ulong,ulonglong# Modified: trunk/numpy/core/tests/test_regression.py =================================================================== --- trunk/numpy/core/tests/test_regression.py 2008-07-20 16:28:04 UTC (rev 5469) +++ trunk/numpy/core/tests/test_regression.py 2008-07-20 19:24:54 UTC (rev 5470) @@ -1124,7 +1124,7 @@ assert dat.T.info == 'jubba' assert dat.var(1).info == 'jubba' assert dat.view(TestArray).info == 'jubba' - + def test_recarray_tolist(self, level=rlevel): """Ticket #793, changeset r5215 """ @@ -1163,6 +1163,13 @@ x = np.array([('a',u'b')], dtype=t) assert_equal(str(x), "[('a', u'b')]", err_msg=msg) + def check_sign_for_complex_nan(self, level=rlevel): + """Ticket 794.""" + C = np.array([-np.inf, -2+1j, 0, 2-1j, np.inf, np.nan]) + have = np.sign(C) + want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, np.nan+0j]) + assert_equal(have, want) + if __name__ == "__main__": run_module_suite() From numpy-svn at scipy.org Sun Jul 20 15:29:32 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 14:29:32 -0500 (CDT) Subject: [Numpy-svn] r5471 - branches/1.1.x/numpy/core/src Message-ID: <20080720192932.7CC2D39C504@scipy.org> Author: charris Date: 2008-07-20 14:29:30 -0500 (Sun, 20 Jul 2008) New Revision: 5471 Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src Log: Replace bogus repeat1 with repeat. Doesn't change generator behavior. Modified: branches/1.1.x/numpy/core/src/scalartypes.inc.src =================================================================== --- branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-20 19:24:54 UTC (rev 5470) +++ branches/1.1.x/numpy/core/src/scalartypes.inc.src 2008-07-20 19:29:30 UTC (rev 5471) @@ -1886,7 +1886,7 @@ #define _WORKz _WORK(0) #define _WORK0 -/**begin repeat1 +/**begin repeat #name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, object# #TYPE=BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, OBJECT# #work=0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,z,z,1# From numpy-svn at scipy.org Sun Jul 20 15:30:41 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 14:30:41 -0500 (CDT) Subject: [Numpy-svn] r5472 - in branches/1.1.x/numpy/core: src tests Message-ID: <20080720193041.21A4839C504@scipy.org> Author: charris Date: 2008-07-20 14:30:37 -0500 (Sun, 20 Jul 2008) New Revision: 5472 Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src branches/1.1.x/numpy/core/tests/test_regression.py Log: Fix ticket #794. Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src =================================================================== --- branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-20 19:29:30 UTC (rev 5471) +++ branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-20 19:30:37 UTC (rev 5472) @@ -1682,9 +1682,15 @@ #define BOOL_negative BOOL_logical_not -#define _SIGN1(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) +#define _SIGN1(x) (isnan((x)) ? NAN : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) #define _SIGN2(x) ((x) == 0 ? 0 : 1) -#define _SIGNC(x) (((x).real > 0) ? 1 : ((x).real < 0 ? -1 : ((x).imag > 0 ? 1 : ((x).imag < 0) ? -1 : 0))) +#define _SIGNC(x) (isnan((x.real)) ? NAN : \ + isnan((x.imag)) ? NAN : \ + ((x).real > 0) ? 1 : \ + ((x).real < 0 ? -1 : \ + ((x).imag > 0 ? 1 : \ + ((x).imag < 0) ? -1 : 0))) + /**begin repeat #TYPE=BYTE,SHORT,INT,LONG,LONGLONG,FLOAT,DOUBLE,LONGDOUBLE,UBYTE,USHORT,UINT,ULONG,ULONGLONG# #typ=byte,short,int,long,longlong,float,double,longdouble,ubyte,ushort,uint,ulong,ulonglong# Modified: branches/1.1.x/numpy/core/tests/test_regression.py =================================================================== --- branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 19:29:30 UTC (rev 5471) +++ branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 19:30:37 UTC (rev 5472) @@ -1084,6 +1084,13 @@ b = np.array(['1','2','3']) assert_equal(a,b) + def check_sign_for_complex_nan(self, level=rlevel): + """Ticket 794.""" + C = np.array([-np.inf, -2+1j, 0, 2-1j, np.inf, np.nan]) + have = np.sign(C) + want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, np.nan+0j]) + assert_equal(have, want) + if __name__ == "__main__": NumpyTest().run() From numpy-svn at scipy.org Sun Jul 20 15:33:01 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 14:33:01 -0500 (CDT) Subject: [Numpy-svn] r5473 - branches/1.1.x/numpy/lib Message-ID: <20080720193301.A88CE39C23D@scipy.org> Author: charris Date: 2008-07-20 14:32:59 -0500 (Sun, 20 Jul 2008) New Revision: 5473 Modified: branches/1.1.x/numpy/lib/format.py Log: Backport r5465. Modified: branches/1.1.x/numpy/lib/format.py =================================================================== --- branches/1.1.x/numpy/lib/format.py 2008-07-20 19:30:37 UTC (rev 5472) +++ branches/1.1.x/numpy/lib/format.py 2008-07-20 19:32:59 UTC (rev 5473) @@ -244,7 +244,7 @@ # Sanity-check the values. if (not isinstance(d['shape'], tuple) or - not numpy.all([isinstance(x, int) for x in d['shape']])): + not numpy.all([isinstance(x, (int,long)) for x in d['shape']])): msg = "shape is not valid: %r" raise ValueError(msg % (d['shape'],)) if not isinstance(d['fortran_order'], bool): From numpy-svn at scipy.org Sun Jul 20 16:35:07 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 15:35:07 -0500 (CDT) Subject: [Numpy-svn] r5474 - trunk/numpy/core/src Message-ID: <20080720203507.60F9939C20E@scipy.org> Author: charris Date: 2008-07-20 15:35:02 -0500 (Sun, 20 Jul 2008) New Revision: 5474 Modified: trunk/numpy/core/src/umathmodule.c.src Log: Fix _SIGN macros for MSVC compilers. Test. Modified: trunk/numpy/core/src/umathmodule.c.src =================================================================== --- trunk/numpy/core/src/umathmodule.c.src 2008-07-20 19:32:59 UTC (rev 5473) +++ trunk/numpy/core/src/umathmodule.c.src 2008-07-20 20:35:02 UTC (rev 5474) @@ -1683,10 +1683,10 @@ #define BOOL_negative BOOL_logical_not -#define _SIGN1(x) (isnan((x)) ? NAN : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) +#define _SIGN1(x) (isnan((x)) ? (x) : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) #define _SIGN2(x) ((x) == 0 ? 0 : 1) -#define _SIGNC(x) (isnan((x.real)) ? NAN : \ - isnan((x.imag)) ? NAN : \ +#define _SIGNC(x) (isnan((x).real) ? (x).real : \ + isnan((x).imag) ? (x).imag : \ ((x).real > 0) ? 1 : \ ((x).real < 0 ? -1 : \ ((x).imag > 0 ? 1 : \ From numpy-svn at scipy.org Sun Jul 20 17:19:29 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 16:19:29 -0500 (CDT) Subject: [Numpy-svn] r5475 - branches/1.1.x/numpy/core/src Message-ID: <20080720211929.3657339C24F@scipy.org> Author: charris Date: 2008-07-20 16:19:26 -0500 (Sun, 20 Jul 2008) New Revision: 5475 Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src Log: Fix use of NAN for MSVC platforms. Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src =================================================================== --- branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-20 20:35:02 UTC (rev 5474) +++ branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-20 21:19:26 UTC (rev 5475) @@ -1682,10 +1682,10 @@ #define BOOL_negative BOOL_logical_not -#define _SIGN1(x) (isnan((x)) ? NAN : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) +#define _SIGN1(x) (isnan((x)) ? (x) : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) #define _SIGN2(x) ((x) == 0 ? 0 : 1) -#define _SIGNC(x) (isnan((x.real)) ? NAN : \ - isnan((x.imag)) ? NAN : \ +#define _SIGNC(x) (isnan((x).real) ? (x).real : \ + isnan((x).imag) ? (x).imag : \ ((x).real > 0) ? 1 : \ ((x).real < 0 ? -1 : \ ((x).imag > 0 ? 1 : \ From numpy-svn at scipy.org Sun Jul 20 17:55:45 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 16:55:45 -0500 (CDT) Subject: [Numpy-svn] r5476 - branches/1.1.x/numpy/core/tests Message-ID: <20080720215545.3BC4139C645@scipy.org> Author: charris Date: 2008-07-20 16:55:43 -0500 (Sun, 20 Jul 2008) New Revision: 5476 Modified: branches/1.1.x/numpy/core/tests/test_regression.py Log: debugging printout. Modified: branches/1.1.x/numpy/core/tests/test_regression.py =================================================================== --- branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 21:19:26 UTC (rev 5475) +++ branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 21:55:43 UTC (rev 5476) @@ -1059,6 +1059,8 @@ """ a = np.recarray(2, formats="i4,f8,f8", names="id,x,y") b = a.tolist() + print a[0].tolist(), b[0] + print a[1].tolist(), b[1]) assert( a[0].tolist() == b[0]) assert( a[1].tolist() == b[1]) From numpy-svn at scipy.org Sun Jul 20 18:52:42 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 17:52:42 -0500 (CDT) Subject: [Numpy-svn] r5477 - trunk/numpy/core/src Message-ID: <20080720225242.2B8AD39C6A6@scipy.org> Author: charris Date: 2008-07-20 17:52:40 -0500 (Sun, 20 Jul 2008) New Revision: 5477 Modified: trunk/numpy/core/src/umathmodule.c.src Log: Revert r5470. Modified: trunk/numpy/core/src/umathmodule.c.src =================================================================== --- trunk/numpy/core/src/umathmodule.c.src 2008-07-20 21:55:43 UTC (rev 5476) +++ trunk/numpy/core/src/umathmodule.c.src 2008-07-20 22:52:40 UTC (rev 5477) @@ -1683,15 +1683,9 @@ #define BOOL_negative BOOL_logical_not -#define _SIGN1(x) (isnan((x)) ? (x) : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) +#define _SIGN1(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) #define _SIGN2(x) ((x) == 0 ? 0 : 1) -#define _SIGNC(x) (isnan((x).real) ? (x).real : \ - isnan((x).imag) ? (x).imag : \ - ((x).real > 0) ? 1 : \ - ((x).real < 0 ? -1 : \ - ((x).imag > 0 ? 1 : \ - ((x).imag < 0) ? -1 : 0))) - +#define _SIGNC(x) (((x).real > 0) ? 1 : ((x).real < 0 ? -1 : ((x).imag > 0 ? 1 : ((x).imag < 0) ? -1 : 0))) /**begin repeat #TYPE=BYTE,SHORT,INT,LONG,LONGLONG,FLOAT,DOUBLE,LONGDOUBLE,UBYTE,USHORT,UINT,ULONG,ULONGLONG# #typ=byte,short,int,long,longlong,float,double,longdouble,ubyte,ushort,uint,ulong,ulonglong# From numpy-svn at scipy.org Sun Jul 20 18:56:44 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 17:56:44 -0500 (CDT) Subject: [Numpy-svn] r5478 - branches/1.1.x/numpy/core/src Message-ID: <20080720225644.1497639C6A6@scipy.org> Author: charris Date: 2008-07-20 17:56:43 -0500 (Sun, 20 Jul 2008) New Revision: 5478 Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src Log: Revert r5472. Modified: branches/1.1.x/numpy/core/src/umathmodule.c.src =================================================================== --- branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-20 22:52:40 UTC (rev 5477) +++ branches/1.1.x/numpy/core/src/umathmodule.c.src 2008-07-20 22:56:43 UTC (rev 5478) @@ -1682,15 +1682,9 @@ #define BOOL_negative BOOL_logical_not -#define _SIGN1(x) (isnan((x)) ? (x) : ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) ) +#define _SIGN1(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) #define _SIGN2(x) ((x) == 0 ? 0 : 1) -#define _SIGNC(x) (isnan((x).real) ? (x).real : \ - isnan((x).imag) ? (x).imag : \ - ((x).real > 0) ? 1 : \ - ((x).real < 0 ? -1 : \ - ((x).imag > 0 ? 1 : \ - ((x).imag < 0) ? -1 : 0))) - +#define _SIGNC(x) (((x).real > 0) ? 1 : ((x).real < 0 ? -1 : ((x).imag > 0 ? 1 : ((x).imag < 0) ? -1 : 0))) /**begin repeat #TYPE=BYTE,SHORT,INT,LONG,LONGLONG,FLOAT,DOUBLE,LONGDOUBLE,UBYTE,USHORT,UINT,ULONG,ULONGLONG# #typ=byte,short,int,long,longlong,float,double,longdouble,ubyte,ushort,uint,ulong,ulonglong# From numpy-svn at scipy.org Sun Jul 20 19:26:43 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 18:26:43 -0500 (CDT) Subject: [Numpy-svn] r5479 - branches/1.1.x/numpy/core/tests Message-ID: <20080720232643.4E9AA39C675@scipy.org> Author: charris Date: 2008-07-20 18:26:40 -0500 (Sun, 20 Jul 2008) New Revision: 5479 Modified: branches/1.1.x/numpy/core/tests/test_regression.py Log: fix typo Modified: branches/1.1.x/numpy/core/tests/test_regression.py =================================================================== --- branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 22:56:43 UTC (rev 5478) +++ branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 23:26:40 UTC (rev 5479) @@ -1060,7 +1060,7 @@ a = np.recarray(2, formats="i4,f8,f8", names="id,x,y") b = a.tolist() print a[0].tolist(), b[0] - print a[1].tolist(), b[1]) + print a[1].tolist(), b[1] assert( a[0].tolist() == b[0]) assert( a[1].tolist() == b[1]) From numpy-svn at scipy.org Sun Jul 20 19:34:14 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 18:34:14 -0500 (CDT) Subject: [Numpy-svn] r5480 - trunk/numpy/core/tests Message-ID: <20080720233414.E38D239C70D@scipy.org> Author: charris Date: 2008-07-20 18:34:11 -0500 (Sun, 20 Jul 2008) New Revision: 5480 Modified: trunk/numpy/core/tests/test_regression.py Log: Make regression test work for reverted NaN fix. Modified: trunk/numpy/core/tests/test_regression.py =================================================================== --- trunk/numpy/core/tests/test_regression.py 2008-07-20 23:26:40 UTC (rev 5479) +++ trunk/numpy/core/tests/test_regression.py 2008-07-20 23:34:11 UTC (rev 5480) @@ -1167,7 +1167,7 @@ """Ticket 794.""" C = np.array([-np.inf, -2+1j, 0, 2-1j, np.inf, np.nan]) have = np.sign(C) - want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, np.nan+0j]) + want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, 0+0j]) assert_equal(have, want) From numpy-svn at scipy.org Sun Jul 20 19:35:50 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 18:35:50 -0500 (CDT) Subject: [Numpy-svn] r5481 - branches/1.1.x/numpy/core/tests Message-ID: <20080720233550.657CD39C70D@scipy.org> Author: charris Date: 2008-07-20 18:35:47 -0500 (Sun, 20 Jul 2008) New Revision: 5481 Modified: branches/1.1.x/numpy/core/tests/test_regression.py Log: make regression test work for reverted NaN fix. Modified: branches/1.1.x/numpy/core/tests/test_regression.py =================================================================== --- branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 23:34:11 UTC (rev 5480) +++ branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 23:35:47 UTC (rev 5481) @@ -1090,7 +1090,7 @@ """Ticket 794.""" C = np.array([-np.inf, -2+1j, 0, 2-1j, np.inf, np.nan]) have = np.sign(C) - want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, np.nan+0j]) + want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, 0+0j]) assert_equal(have, want) From numpy-svn at scipy.org Sun Jul 20 19:58:51 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 18:58:51 -0500 (CDT) Subject: [Numpy-svn] r5482 - branches/1.1.x/numpy/core/tests Message-ID: <20080720235851.B571839C70D@scipy.org> Author: charris Date: 2008-07-20 18:58:48 -0500 (Sun, 20 Jul 2008) New Revision: 5482 Modified: branches/1.1.x/numpy/core/tests/test_regression.py Log: Fix broken regression test. Modified: branches/1.1.x/numpy/core/tests/test_regression.py =================================================================== --- branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 23:35:47 UTC (rev 5481) +++ branches/1.1.x/numpy/core/tests/test_regression.py 2008-07-20 23:58:48 UTC (rev 5482) @@ -1057,10 +1057,11 @@ def check_recarray_tolist(self, level=rlevel): """Ticket #793, changeset r5215 """ - a = np.recarray(2, formats="i4,f8,f8", names="id,x,y") + # Comparisons fail for NaN, so we can't use random memory + # for the test. + buf = np.zeros(40, dtype=np.int8) + a = np.recarray(2, formats="i4,f8,f8", names="id,x,y", buf=buf) b = a.tolist() - print a[0].tolist(), b[0] - print a[1].tolist(), b[1] assert( a[0].tolist() == b[0]) assert( a[1].tolist() == b[1]) From numpy-svn at scipy.org Sun Jul 20 19:59:32 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 18:59:32 -0500 (CDT) Subject: [Numpy-svn] r5483 - trunk/numpy/core/tests Message-ID: <20080720235932.9967839C70D@scipy.org> Author: charris Date: 2008-07-20 18:59:29 -0500 (Sun, 20 Jul 2008) New Revision: 5483 Modified: trunk/numpy/core/tests/test_regression.py Log: Fix broken regression test. Modified: trunk/numpy/core/tests/test_regression.py =================================================================== --- trunk/numpy/core/tests/test_regression.py 2008-07-20 23:58:48 UTC (rev 5482) +++ trunk/numpy/core/tests/test_regression.py 2008-07-20 23:59:29 UTC (rev 5483) @@ -1128,7 +1128,10 @@ def test_recarray_tolist(self, level=rlevel): """Ticket #793, changeset r5215 """ - a = np.recarray(2, formats="i4,f8,f8", names="id,x,y") + # Comparisons fail for NaN, so we can't use random memory + # for the test. + buf = np.zeros(40, dtype=np.int8) + a = np.recarray(2, formats="i4,f8,f8", names="id,x,y", buf=buf) b = a.tolist() assert( a[0].tolist() == b[0]) assert( a[1].tolist() == b[1]) From numpy-svn at scipy.org Sun Jul 20 20:28:17 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 20 Jul 2008 19:28:17 -0500 (CDT) Subject: [Numpy-svn] r5484 - in branches/1.1.x/numpy: core distutils random Message-ID: <20080721002817.EBEC539C712@scipy.org> Author: charris Date: 2008-07-20 19:28:13 -0500 (Sun, 20 Jul 2008) New Revision: 5484 Modified: branches/1.1.x/numpy/core/setup.py branches/1.1.x/numpy/distutils/misc_util.py branches/1.1.x/numpy/random/setup.py Log: Bring back reverted r5461. Error was in the regression test. Modified: branches/1.1.x/numpy/core/setup.py =================================================================== --- branches/1.1.x/numpy/core/setup.py 2008-07-20 23:59:29 UTC (rev 5483) +++ branches/1.1.x/numpy/core/setup.py 2008-07-21 00:28:13 UTC (rev 5484) @@ -65,7 +65,10 @@ header_dir = 'include/numpy' # this is relative to config.path_in_package def generate_config_h(ext, build_dir): - target = join(build_dir,'config.h') + target = join(build_dir,header_dir,'config.h') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) if newer(__file__,target): config_cmd = config.get_config_cmd() log.info('Generating %s',target) @@ -159,7 +162,10 @@ def generate_numpyconfig_h(ext, build_dir): """Depends on config.h: generate_config_h has to be called before !""" - target = join(build_dir,'numpyconfig.h') + target = join(build_dir,header_dir,'numpyconfig.h') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) if newer(__file__,target): config_cmd = config.get_config_cmd() log.info('Generating %s',target) @@ -198,7 +204,7 @@ try: m = __import__(module_name) log.info('executing %s', script) - h_file, c_file, doc_file = m.generate_api(build_dir) + h_file, c_file, doc_file = m.generate_api(os.path.join(build_dir, header_dir)) finally: del sys.path[0] config.add_data_files((header_dir, h_file), @@ -210,7 +216,10 @@ generate_ufunc_api = generate_api_func('generate_ufunc_api') def generate_umath_c(ext,build_dir): - target = join(build_dir,'__umath_generated.c') + target = join(build_dir,header_dir,'__umath_generated.c') + dir = os.path.dirname(target) + if not os.path.exists(dir): + os.makedirs(dir) script = generate_umath_py if newer(script,target): f = open(target,'w') Modified: branches/1.1.x/numpy/distutils/misc_util.py =================================================================== --- branches/1.1.x/numpy/distutils/misc_util.py 2008-07-20 23:59:29 UTC (rev 5483) +++ branches/1.1.x/numpy/distutils/misc_util.py 2008-07-21 00:28:13 UTC (rev 5484) @@ -114,9 +114,20 @@ def get_mathlibs(path=None): """Return the MATHLIB line from numpyconfig.h """ - if path is None: - path = os.path.join(get_numpy_include_dirs()[0], 'numpy') - config_file = os.path.join(path,'numpyconfig.h') + if path is not None: + config_file = os.path.join(path,'numpyconfig.h') + else: + # Look for the file in each of the numpy include directories. + dirs = get_numpy_include_dirs() + for path in dirs: + fn = os.path.join(path,'numpyconfig.h') + if os.path.exists(fn): + config_file = fn + break + else: + raise DistutilsError('numpyconfig.h not found in numpy include ' + 'dirs %r' % (dirs,)) + fid = open(config_file) mathlibs = [] s = '#define MATHLIB' Modified: branches/1.1.x/numpy/random/setup.py =================================================================== --- branches/1.1.x/numpy/random/setup.py 2008-07-20 23:59:29 UTC (rev 5483) +++ branches/1.1.x/numpy/random/setup.py 2008-07-21 00:28:13 UTC (rev 5484) @@ -6,11 +6,7 @@ def generate_libraries(ext, build_dir): config_cmd = config.get_config_cmd() - if top_path is None: - libs = get_mathlibs() - else: - path = join(split(build_dir)[0],'core') - libs = get_mathlibs(path) + libs = get_mathlibs() tc = testcode_wincrypt() if config_cmd.try_run(tc): libs.append('Advapi32') From numpy-svn at scipy.org Mon Jul 21 02:30:07 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 01:30:07 -0500 (CDT) Subject: [Numpy-svn] r5485 - trunk/numpy/core/tests Message-ID: <20080721063007.A5FF039C232@scipy.org> Author: alan.mcintyre Date: 2008-07-21 01:29:58 -0500 (Mon, 21 Jul 2008) New Revision: 5485 Modified: trunk/numpy/core/tests/test_defmatrix.py trunk/numpy/core/tests/test_multiarray.py trunk/numpy/core/tests/test_numeric.py trunk/numpy/core/tests/test_records.py trunk/numpy/core/tests/test_regression.py Log: Added tests to improve coverage of numpy.core. Removed unused methods from Vec class in test_numeric.py. Renamed test in test_regression so it would be seen by nose. Removed commented test_vector_elements test in test_defmatrix.py (same tems are now tested in test_matrix_element). Modified: trunk/numpy/core/tests/test_defmatrix.py =================================================================== --- trunk/numpy/core/tests/test_defmatrix.py 2008-07-21 00:28:13 UTC (rev 5484) +++ trunk/numpy/core/tests/test_defmatrix.py 2008-07-21 06:29:58 UTC (rev 5485) @@ -17,11 +17,37 @@ assert all(B.A == D) assert all(C.A == D) + E = array([[5,6],[7,8]]) + AEresult = matrix([[1,2,5,6],[3,4,7,8]]) + assert all(bmat([A,E]) == AEresult) + vec = arange(5) mvec = matrix(vec) assert mvec.shape == (1,5) + def test_bmat_nondefault_str(self): + A = array([[1,2],[3,4]]) + B = array([[5,6],[7,8]]) + Aresult = array([[1,2,1,2], + [3,4,3,4], + [1,2,1,2], + [3,4,3,4]]) + Bresult = array([[5,6,5,6], + [7,8,7,8], + [5,6,5,6], + [7,8,7,8]]) + mixresult = array([[1,2,5,6], + [3,4,7,8], + [5,6,1,2], + [7,8,3,4]]) + assert all(bmat("A,A;A,A") == Aresult) + assert all(bmat("A,A;A,A",ldict={'A':B}) == Aresult) + assert_raises(TypeError, bmat, "A,A;A,A",gdict={'A':B}) + assert all(bmat("A,A;A,A",ldict={'A':A},gdict={'A':B}) == Aresult) + b2 = bmat("A,B;C,D",ldict={'A':A,'B':B},gdict={'C':B,'D':A}) + assert all(b2 == mixresult) + class TestProperties(TestCase): def test_sum(self): """Test whether matrix.sum(axis=1) preserves orientation. @@ -38,6 +64,34 @@ assert_array_equal(sum1, M.sum(axis=1)) assert sumall == M.sum() + + def test_prod(self): + x = matrix([[1,2,3],[4,5,6]]) + assert x.prod() == 720 + assert all(x.prod(0) == matrix([[4,10,18]])) + assert all(x.prod(1) == matrix([[6],[120]])) + + y = matrix([0,1,3]) + assert y.prod() == 0 + + def test_max(self): + x = matrix([[1,2,3],[4,5,6]]) + assert x.max() == 6 + assert all(x.max(0) == matrix([[4,5,6]])) + assert all(x.max(1) == matrix([[3],[6]])) + + def test_min(self): + x = matrix([[1,2,3],[4,5,6]]) + assert x.min() == 1 + assert all(x.min(0) == matrix([[1,2,3]])) + assert all(x.min(1) == matrix([[1],[4]])) + + def test_ptp(self): + x = np.arange(4).reshape((2,2)) + assert x.ptp() == 3 + assert all(x.ptp(0) == array([2, 2])) + assert all(x.ptp(1) == array([1, 1])) + def test_basic(self): import numpy.linalg as linalg @@ -55,6 +109,13 @@ assert all(array(transpose(B) == mB.T)) assert all(array(conjugate(transpose(B)) == mB.H)) + def test_pinv(self): + x = matrix(arange(6).reshape(2,3)) + xpinv = matrix([[-0.77777778, 0.27777778], + [-0.11111111, 0.11111111], + [ 0.55555556, -0.05555556]]) + assert_almost_equal(x.I, xpinv) + def test_comparisons(self): A = arange(100).reshape(10,10) mA = matrix(A) @@ -241,14 +302,9 @@ assert isinstance(x, matrix) assert_equal(x, matrix([[4, 3], [1, 2]])) -# def test_vector_element(self): -# x = matrix([[1,2,3],[4,5,6]]) -# assert_equal(x[0][0],1) -# assert_equal(x[0].shape,(1,3)) -# assert_equal(x[:,0].shape,(2,1)) - def test_matrix_element(self): x = matrix([[1,2,3],[4,5,6]]) + assert_equal(x[0][0],matrix([[1,2,3]])) assert_equal(x[0][0].shape,(1,3)) assert_equal(x[0].shape,(1,3)) assert_equal(x[:,0].shape,(2,1)) Modified: trunk/numpy/core/tests/test_multiarray.py =================================================================== --- trunk/numpy/core/tests/test_multiarray.py 2008-07-21 00:28:13 UTC (rev 5484) +++ trunk/numpy/core/tests/test_multiarray.py 2008-07-21 06:29:58 UTC (rev 5485) @@ -397,6 +397,29 @@ # d.sort(axis=None) #assert_equal(d, c, "test sort with axis=None") + + def test_sort_order(self): + # Test sorting an array with fields + x1=np.array([21,32,14]) + x2=np.array(['my','first','name']) + x3=np.array([3.1,4.5,6.2]) + r=np.rec.fromarrays([x1,x2,x3],names='id,word,number') + + r.sort(order=['id']) + assert_equal(r.id, array([14,21,32])) + assert_equal(r.word, array(['name','my','first'])) + assert_equal(r.number, array([6.2,3.1,4.5])) + + r.sort(order=['word']) + assert_equal(r.id, array([32,21,14])) + assert_equal(r.word, array(['first','my','name'])) + assert_equal(r.number, array([4.5,3.1,6.2])) + + r.sort(order=['number']) + assert_equal(r.id, array([21,32,14])) + assert_equal(r.word, array(['my','first','name'])) + assert_equal(r.number, array([3.1,4.5,6.2])) + def test_argsort(self): # all c scalar argsorts use the same code with different types # so it suffices to run a quick check with one type. The number Modified: trunk/numpy/core/tests/test_numeric.py =================================================================== --- trunk/numpy/core/tests/test_numeric.py 2008-07-21 00:28:13 UTC (rev 5484) +++ trunk/numpy/core/tests/test_numeric.py 2008-07-21 06:29:58 UTC (rev 5485) @@ -23,13 +23,6 @@ return out def __rmul__(self,other): return self*other - def __abs__(self): - out=Vec() - out.array=abs(self.array) - return out - def __repr__(self): - return "Vec("+repr(self.array.tolist())+")" - __str__=__repr__ class TestDot(TestCase): @@ -142,6 +135,59 @@ assert_equal(zeros[1].array, zeros_test[1].array) +class TestResize(TestCase): + def test_copies(self): + A = array([[1,2],[3,4]]) + Ar1 = array([[1,2,3,4],[1,2,3,4]]) + assert_equal(resize(A, (2,4)), Ar1) + + Ar2 = array([[1,2],[3,4],[1,2],[3,4]]) + assert_equal(resize(A, (4,2)), Ar2) + + Ar3 = array([[1,2,3],[4,1,2],[3,4,1],[2,3,4]]) + assert_equal(resize(A, (4,3)), Ar3) + + def test_zeroresize(self): + A = array([[1,2],[3,4]]) + Ar = resize(A, (0,)) + assert_equal(Ar, array([])) + + +class TestNonarrayArgs(TestCase): + # check that non-array arguments to functions wrap them in arrays + def test_squeeze(self): + A = [[[1,1,1],[2,2,2],[3,3,3]]] + assert squeeze(A).shape == (3,3) + + def test_cumproduct(self): + A = [[1,2,3],[4,5,6]] + assert all(cumproduct(A) == array([1,2,6,24,120,720])) + + def test_size(self): + A = [[1,2,3],[4,5,6]] + assert size(A) == 6 + assert size(A,0) == 2 + assert size(A,1) == 3 + + def test_mean(self): + A = [[1,2,3],[4,5,6]] + assert mean(A) == 3.5 + assert all(mean(A,0) == array([2.5,3.5,4.5])) + assert all(mean(A,1) == array([2.,5.])) + + def test_std(self): + A = [[1,2,3],[4,5,6]] + assert_almost_equal(std(A), 1.707825127659933) + assert_almost_equal(std(A,0), array([1.5, 1.5, 1.5])) + assert_almost_equal(std(A,1), array([0.81649658, 0.81649658])) + + def test_var(self): + A = [[1,2,3],[4,5,6]] + assert_almost_equal(var(A), 2.9166666666666665) + assert_almost_equal(var(A,0), array([2.25, 2.25, 2.25])) + assert_almost_equal(var(A,1), array([0.66666667, 0.66666667])) + + class TestBoolScalar(TestCase): def test_logical(self): f = False_ Modified: trunk/numpy/core/tests/test_records.py =================================================================== --- trunk/numpy/core/tests/test_records.py 2008-07-21 00:28:13 UTC (rev 5484) +++ trunk/numpy/core/tests/test_records.py 2008-07-21 06:29:58 UTC (rev 5485) @@ -115,6 +115,19 @@ self.failUnlessRaises(AttributeError,assign_invalid_column,a) +def test_find_duplicate(): + l1 = [1,2,3,4,5,6] + assert np.rec.find_duplicate(l1) == [] + + l2 = [1,2,1,4,5,6] + assert np.rec.find_duplicate(l2) == [1] + + l3 = [1,2,1,4,1,6,2,3] + assert np.rec.find_duplicate(l3) == [1,2] + + l3 = [2,2,1,4,1,6,2,3] + assert np.rec.find_duplicate(l3) == [2,1] + if __name__ == "__main__": run_module_suite() Modified: trunk/numpy/core/tests/test_regression.py =================================================================== --- trunk/numpy/core/tests/test_regression.py 2008-07-21 00:28:13 UTC (rev 5484) +++ trunk/numpy/core/tests/test_regression.py 2008-07-21 06:29:58 UTC (rev 5485) @@ -1,3 +1,4 @@ + from StringIO import StringIO import pickle import sys @@ -1166,7 +1167,7 @@ x = np.array([('a',u'b')], dtype=t) assert_equal(str(x), "[('a', u'b')]", err_msg=msg) - def check_sign_for_complex_nan(self, level=rlevel): + def test_sign_for_complex_nan(self, level=rlevel): """Ticket 794.""" C = np.array([-np.inf, -2+1j, 0, 2-1j, np.inf, np.nan]) have = np.sign(C) From numpy-svn at scipy.org Mon Jul 21 02:55:54 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 01:55:54 -0500 (CDT) Subject: [Numpy-svn] r5486 - trunk/numpy/testing Message-ID: <20080721065554.DA25239C2C4@scipy.org> Author: alan.mcintyre Date: 2008-07-21 01:55:48 -0500 (Mon, 21 Jul 2008) New Revision: 5486 Modified: trunk/numpy/testing/nosetester.py trunk/numpy/testing/utils.py Log: Added numpy.testing.verbose, to allow tests to vary output accordingly. Added numpy.testing.print_assert_equal, to allow removing the multiple identical implementations of this function in SciPy tests. Display version info for NumPy, Python, and nose (and SciPy when running SciPy tests), in a manner similar to the original test framework. Modified: trunk/numpy/testing/nosetester.py =================================================================== --- trunk/numpy/testing/nosetester.py 2008-07-21 06:29:58 UTC (rev 5485) +++ trunk/numpy/testing/nosetester.py 2008-07-21 06:55:48 UTC (rev 5486) @@ -183,6 +183,9 @@ # cap verbosity at 3 because nose becomes *very* verbose beyond that verbose = min(verbose, 3) + import utils + utils.verbose = verbose + # if all evaluates as True, omit attribute filter and run doctests if kwargs.get('all'): label = '' @@ -215,6 +218,21 @@ nose = import_nose() + import numpy + print "NumPy version %s" % numpy.__version__ + npdir = os.path.dirname(numpy.__file__) + print "NumPy is installed in %s" % npdir + + if 'scipy' in self.package_name: + import scipy + print "SciPy version %s" % scipy.__version__ + spdir = os.path.dirname(scipy.__file__) + print "SciPy is installed in %s" % spdir + + pyversion = sys.version.replace('\n','') + print "Python version %s" % pyversion + print "nose version %d.%d.%d" % nose.__versioninfo__ + # Because nose currently discards the test result object, but we need # to return it to the user, override TestProgram.runTests to retain # the result Modified: trunk/numpy/testing/utils.py =================================================================== --- trunk/numpy/testing/utils.py 2008-07-21 06:29:58 UTC (rev 5485) +++ trunk/numpy/testing/utils.py 2008-07-21 06:55:48 UTC (rev 5486) @@ -13,9 +13,11 @@ __all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal', 'assert_array_equal', 'assert_array_less', 'assert_string_equal', 'assert_array_almost_equal', 'assert_raises', 'build_err_msg', - 'decorate_methods', 'jiffies', 'memusage', 'raises', 'rand', - 'rundocs', 'runstring'] + 'decorate_methods', 'jiffies', 'memusage', 'print_assert_equal', + 'raises', 'rand', 'rundocs', 'runstring', 'verbose'] +verbose = 0 + def rand(*args): """Returns an array of random numbers with the given shape. @@ -147,6 +149,20 @@ msg = build_err_msg([actual, desired], err_msg, verbose=verbose) assert desired == actual, msg +def print_assert_equal(test_string,actual,desired): + import pprint + try: + assert(actual == desired) + except AssertionError: + import cStringIO + msg = cStringIO.StringIO() + msg.write(test_string) + msg.write(' failed\nACTUAL: \n') + pprint.pprint(actual,msg) + msg.write('DESIRED: \n') + pprint.pprint(desired,msg) + raise AssertionError, msg.getvalue() + def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True): """ Raise an assertion if two items are not equal. From numpy-svn at scipy.org Mon Jul 21 08:36:19 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 07:36:19 -0500 (CDT) Subject: [Numpy-svn] r5487 - trunk/numpy/lib Message-ID: <20080721123619.2A8A039C5DC@scipy.org> Author: alan.mcintyre Date: 2008-07-21 07:36:17 -0500 (Mon, 21 Jul 2008) New Revision: 5487 Modified: trunk/numpy/lib/function_base.py Log: Removed unused private function _asarray1d. Modified: trunk/numpy/lib/function_base.py =================================================================== --- trunk/numpy/lib/function_base.py 2008-07-21 06:55:48 UTC (rev 5486) +++ trunk/numpy/lib/function_base.py 2008-07-21 12:36:17 UTC (rev 5487) @@ -657,14 +657,6 @@ S = S*ones(asarray(pfac).shape, S.dtype) return choose(S, tuple(choicelist)) -def _asarray1d(arr, copy=False): - """Ensure 1D array for one array. - """ - if copy: - return asarray(arr).flatten() - else: - return asarray(arr).ravel() - def copy(a): """Return an array copy of the given object. """ From numpy-svn at scipy.org Mon Jul 21 12:15:50 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 11:15:50 -0500 (CDT) Subject: [Numpy-svn] r5488 - tags Message-ID: <20080721161550.F3F2139C343@scipy.org> Author: jarrod.millman Date: 2008-07-21 11:15:46 -0500 (Mon, 21 Jul 2008) New Revision: 5488 Added: tags/1.1.1rc1/ Log: tagged 1.1.1rc1 Copied: tags/1.1.1rc1 (from rev 5487, branches/1.1.x) From numpy-svn at scipy.org Mon Jul 21 12:17:54 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 11:17:54 -0500 (CDT) Subject: [Numpy-svn] r5489 - tags/1.1.1rc1/numpy Message-ID: <20080721161754.E662339C24F@scipy.org> Author: jarrod.millman Date: 2008-07-21 11:17:51 -0500 (Mon, 21 Jul 2008) New Revision: 5489 Modified: tags/1.1.1rc1/numpy/version.py Log: updating version information Modified: tags/1.1.1rc1/numpy/version.py =================================================================== --- tags/1.1.1rc1/numpy/version.py 2008-07-21 16:15:46 UTC (rev 5488) +++ tags/1.1.1rc1/numpy/version.py 2008-07-21 16:17:51 UTC (rev 5489) @@ -1,5 +1,5 @@ -version='1.1.1' -release=False +version='1.1.1rc1' +release=True if not release: version += '.dev' From numpy-svn at scipy.org Mon Jul 21 14:49:53 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 13:49:53 -0500 (CDT) Subject: [Numpy-svn] r5490 - in branches/1.1.x/numpy/ma: . tests Message-ID: <20080721184953.55C0939C2C4@scipy.org> Author: pierregm Date: 2008-07-21 13:49:45 -0500 (Mon, 21 Jul 2008) New Revision: 5490 Modified: branches/1.1.x/numpy/ma/core.py branches/1.1.x/numpy/ma/tests/test_core.py branches/1.1.x/numpy/ma/testutils.py Log: testutils : * backport from 1.2 core: * fixed the reshape function/method to accept an 'order' optional parameter Modified: branches/1.1.x/numpy/ma/core.py =================================================================== --- branches/1.1.x/numpy/ma/core.py 2008-07-21 16:17:51 UTC (rev 5489) +++ branches/1.1.x/numpy/ma/core.py 2008-07-21 18:49:45 UTC (rev 5490) @@ -1867,24 +1867,36 @@ # repeat = _arraymethod('repeat') # - def reshape (self, *s): - """Reshape the array to shape s. + def reshape (self, shape, order='C'): + """ + Returns a masked array containing the data of a, but with a new shape. + The result is a view to the original array; if this is not possible, + a ValueError is raised. - Returns - ------- - A new masked array. + Parameters + ---------- + shape : shape tuple or int + The new shape should be compatible with the original shape. If an + integer, then the result will be a 1D array of that length. + order : {'C', 'F'}, optional + Determines whether the array data should be viewed as in C + (row-major) order or FORTRAN (column-major) order. - Notes - ----- - If you want to modify the shape in place, please use - ``a.shape = s`` + Returns + ------- + reshaped_array : array + A new view to the array. + Notes + ----- + If you want to modify the shape in place, please use ``a.shape = s`` + """ - result = self._data.reshape(*s).view(type(self)) + result = self._data.reshape(shape, order=order).view(type(self)) result._update_from(self) mask = self._mask if mask is not nomask: - result._mask = mask.reshape(*s) + result._mask = mask.reshape(shape, order=order) return result # def resize(self, newshape, refcheck=True, order=False): @@ -3408,13 +3420,13 @@ except AttributeError: return narray(a, copy=False).transpose(axes).view(MaskedArray) -def reshape(a, new_shape): +def reshape(a, new_shape, order='C'): """Change the shape of the array a to new_shape.""" #We can't use 'frommethod', it whine about some parameters. Dmmit. try: - return a.reshape(new_shape) + return a.reshape(new_shape, order=order) except AttributeError: - return narray(a, copy=False).reshape(new_shape).view(MaskedArray) + return narray(a, copy=False).reshape(new_shape, order=order).view(MaskedArray) def resize(x, new_shape): """Return a new array with the specified shape. Modified: branches/1.1.x/numpy/ma/tests/test_core.py =================================================================== --- branches/1.1.x/numpy/ma/tests/test_core.py 2008-07-21 16:17:51 UTC (rev 5489) +++ branches/1.1.x/numpy/ma/tests/test_core.py 2008-07-21 18:49:45 UTC (rev 5490) @@ -865,6 +865,23 @@ assert_equal(xs.dtype, '|S3') + def test_reshape(self): + a = arange(10) + a[0] = masked + # Try the default + b = a.reshape((5,2)) + assert_equal(b.shape, (5,2)) + assert(b.flags['C']) + # Try w/ order + b = a.reshape((5,2), order='F') + assert_equal(b.shape, (5,2)) + assert(b.flags['F']) + # + c = np.reshape(a, (2,5)) + assert(isinstance(c, MaskedArray)) + assert_equal(c.shape, (2,5)) + assert(c[0,0] is masked) + assert(c.flags['C']) #............................................................................... Modified: branches/1.1.x/numpy/ma/testutils.py =================================================================== --- branches/1.1.x/numpy/ma/testutils.py 2008-07-21 16:17:51 UTC (rev 5489) +++ branches/1.1.x/numpy/ma/testutils.py 2008-07-21 18:49:45 UTC (rev 5490) @@ -104,10 +104,18 @@ raise ValueError(msg) actual = np.array(actual, copy=False, subok=True) desired = np.array(desired, copy=False, subok=True) - if actual.dtype.char in "OSV" and desired.dtype.char in "OSV": + if actual_dtype.char == "S" and desired_dtype.char == "S": return _assert_equal_on_sequences(actual.tolist(), desired.tolist(), err_msg='') + elif actual_dtype.char in "OV" and desired_dtype.char in "OV": + if (actual_dtype != desired_dtype) and actual_dtype: + msg = build_err_msg([actual_dtype, desired_dtype], + err_msg, header='', names=('actual', 'desired')) + raise ValueError(msg) + return _assert_equal_on_sequences(actual.tolist(), + desired.tolist(), + err_msg='') return assert_array_equal(actual, desired, err_msg) From numpy-svn at scipy.org Mon Jul 21 14:51:53 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 13:51:53 -0500 (CDT) Subject: [Numpy-svn] r5491 - in trunk/numpy/ma: . tests Message-ID: <20080721185153.37E0C39C2C4@scipy.org> Author: pierregm Date: 2008-07-21 13:51:47 -0500 (Mon, 21 Jul 2008) New Revision: 5491 Modified: trunk/numpy/ma/core.py trunk/numpy/ma/tests/test_core.py trunk/numpy/ma/tests/test_mrecords.py trunk/numpy/ma/tests/test_old_ma.py Log: core: * fixed the reshape function/method to accept an 'order' optional parameter Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-21 18:49:45 UTC (rev 5490) +++ trunk/numpy/ma/core.py 2008-07-21 18:51:47 UTC (rev 5491) @@ -2038,24 +2038,36 @@ # repeat = _arraymethod('repeat') # - def reshape (self, *s): - """Reshape the array to shape s. + def reshape (self, shape, order='C'): + """ + Returns a masked array containing the data of a, but with a new shape. + The result is a view to the original array; if this is not possible, + a ValueError is raised. - Returns - ------- - A new masked array. + Parameters + ---------- + shape : shape tuple or int + The new shape should be compatible with the original shape. If an + integer, then the result will be a 1D array of that length. + order : {'C', 'F'}, optional + Determines whether the array data should be viewed as in C + (row-major) order or FORTRAN (column-major) order. - Notes - ----- - If you want to modify the shape in place, please use - ``a.shape = s`` + Returns + ------- + reshaped_array : array + A new view to the array. + Notes + ----- + If you want to modify the shape in place, please use ``a.shape = s`` + """ - result = self._data.reshape(*s).view(type(self)) + result = self._data.reshape(shape, order=order).view(type(self)) result._update_from(self) mask = self._mask if mask is not nomask: - result._mask = mask.reshape(*s) + result._mask = mask.reshape(shape, order=order) return result # def resize(self, newshape, refcheck=True, order=False): @@ -3066,8 +3078,10 @@ return result #........................ def tostring(self, fill_value=None, order='C'): - """Return a copy of array data as a Python string containing the raw - bytes in the array. + """ + Return a copy of array data as a Python string containing the raw bytes + in the array. + The array is filled beforehand. Parameters ---------- @@ -3081,6 +3095,11 @@ "Any" -- Current order of array. None -- Same as "Any" + Warnings + -------- + As for :meth:`ndarray.tostring`, information about the shape, dtype..., + but also fill_value will be lost. + """ return self.filled(fill_value).tostring(order=order) #........................ @@ -3601,13 +3620,13 @@ except AttributeError: return narray(a, copy=False).transpose(axes).view(MaskedArray) -def reshape(a, new_shape): +def reshape(a, new_shape, order='C'): """Change the shape of the array a to new_shape.""" #We can't use 'frommethod', it whine about some parameters. Dmmit. try: - return a.reshape(new_shape) + return a.reshape(new_shape, order=order) except AttributeError: - return narray(a, copy=False).reshape(new_shape).view(MaskedArray) + return narray(a, copy=False).reshape(new_shape, order=order).view(MaskedArray) def resize(x, new_shape): """Return a new array with the specified shape. Modified: trunk/numpy/ma/tests/test_core.py =================================================================== --- trunk/numpy/ma/tests/test_core.py 2008-07-21 18:49:45 UTC (rev 5490) +++ trunk/numpy/ma/tests/test_core.py 2008-07-21 18:51:47 UTC (rev 5491) @@ -60,7 +60,7 @@ x = masked_array(0, mask=False) assert_equal(str(x), '0') x = array(0, mask=1) - assert(x.filled().dtype is x.data.dtype) + assert(x.filled().dtype is x._data.dtype) def test_basic1d(self): @@ -753,7 +753,7 @@ xs[[1,4]] = [10,40] assert_equal(xh._data, [0,10,2,3,4]) assert_equal(xs._data, [0,10,2,3,40]) - #assert_equal(xh.mask.ctypes.data, m.ctypes.data) + #assert_equal(xh.mask.ctypes._data, m.ctypes._data) assert_equal(xs.mask, [0,0,0,1,0]) assert(xh._hardmask) assert(not xs._hardmask) @@ -761,7 +761,7 @@ xs[1:4] = [10,20,30] assert_equal(xh._data, [0,10,20,3,4]) assert_equal(xs._data, [0,10,20,30,40]) - #assert_equal(xh.mask.ctypes.data, m.ctypes.data) + #assert_equal(xh.mask.ctypes._data, m.ctypes._data) assert_equal(xs.mask, nomask) xh[0] = masked xs[0] = masked @@ -804,7 +804,7 @@ m = make_mask(n) xh = array(d, mask = m, hard_mask=True) xh[4:5] = 999 - #assert_equal(xh.mask.ctypes.data, m.ctypes.data) + #assert_equal(xh.mask.ctypes._data, m.ctypes._data) xh[0:1] = 999 assert_equal(xh._data,[999,1,2,3,4]) @@ -1047,9 +1047,9 @@ # warnings.simplefilter('ignore', DeprecationWarning) (x, _, xm) = self.floatdata - id1 = x.raw_data().ctypes.data + id1 = x.raw_data().ctypes._data x += 1. - assert (id1 == x.raw_data().ctypes.data) + assert (id1 == x.raw_data().ctypes._data) assert_equal(x, y+1.) warnings.simplefilter('default', DeprecationWarning) @@ -1195,20 +1195,20 @@ "Tests some MaskedArray methods." a = array([1,3,2]) b = array([1,3,2], mask=[1,0,1]) - assert_equal(a.any(), a.data.any()) - assert_equal(a.all(), a.data.all()) - assert_equal(a.argmax(), a.data.argmax()) - assert_equal(a.argmin(), a.data.argmin()) - assert_equal(a.choose(0,1,2,3,4), a.data.choose(0,1,2,3,4)) - assert_equal(a.compress([1,0,1]), a.data.compress([1,0,1])) - assert_equal(a.conj(), a.data.conj()) - assert_equal(a.conjugate(), a.data.conjugate()) + assert_equal(a.any(), a._data.any()) + assert_equal(a.all(), a._data.all()) + assert_equal(a.argmax(), a._data.argmax()) + assert_equal(a.argmin(), a._data.argmin()) + assert_equal(a.choose(0,1,2,3,4), a._data.choose(0,1,2,3,4)) + assert_equal(a.compress([1,0,1]), a._data.compress([1,0,1])) + assert_equal(a.conj(), a._data.conj()) + assert_equal(a.conjugate(), a._data.conjugate()) # m = array([[1,2],[3,4]]) - assert_equal(m.diagonal(), m.data.diagonal()) - assert_equal(a.sum(), a.data.sum()) - assert_equal(a.take([1,2]), a.data.take([1,2])) - assert_equal(m.transpose(), m.data.transpose()) + assert_equal(m.diagonal(), m._data.diagonal()) + assert_equal(a.sum(), a._data.sum()) + assert_equal(a.take([1,2]), a._data.take([1,2])) + assert_equal(m.transpose(), m._data.transpose()) def test_allany(self): @@ -1325,8 +1325,8 @@ mx = array(x,mask=m) clipped = mx.clip(2,8) assert_equal(clipped.mask,mx.mask) - assert_equal(clipped.data,x.clip(2,8)) - assert_equal(clipped.data,mx.data.clip(2,8)) + assert_equal(clipped._data,x.clip(2,8)) + assert_equal(clipped._data,mx._data.clip(2,8)) def test_compress(self): @@ -1724,14 +1724,14 @@ "Tests cumsum & cumprod on MaskedArrays." (x,X,XX,m,mx,mX,mXX,m2x,m2X,m2XX) = self.d mXcp = mX.cumsum(0) - assert_equal(mXcp.data,mX.filled(0).cumsum(0)) + assert_equal(mXcp._data,mX.filled(0).cumsum(0)) mXcp = mX.cumsum(1) - assert_equal(mXcp.data,mX.filled(0).cumsum(1)) + assert_equal(mXcp._data,mX.filled(0).cumsum(1)) # mXcp = mX.cumprod(0) - assert_equal(mXcp.data,mX.filled(1).cumprod(0)) + assert_equal(mXcp._data,mX.filled(1).cumprod(0)) mXcp = mX.cumprod(1) - assert_equal(mXcp.data,mX.filled(1).cumprod(1)) + assert_equal(mXcp._data,mX.filled(1).cumprod(1)) def test_cumsumprod_with_output(self): @@ -2143,6 +2143,24 @@ assert_equal(store, array([999999, 31, 12, 999999])) + def test_reshape(self): + a = arange(10) + a[0] = masked + # Try the default + b = a.reshape((5,2)) + assert_equal(b.shape, (5,2)) + assert(b.flags['C']) + # Try w/ order + b = a.reshape((5,2), order='F') + assert_equal(b.shape, (5,2)) + assert(b.flags['F']) + # + c = np.reshape(a, (2,5)) + assert(isinstance(c, MaskedArray)) + assert_equal(c.shape, (2,5)) + assert(c[0,0] is masked) + assert(c.flags['C']) + #------------------------------------------------------------------------------ class TestMaskedFields(TestCase): @@ -2183,13 +2201,13 @@ base[0] = (pi, pi, 'pi') assert_equal(base_a.dtype, int) - assert_equal(base_a.data, [3,2,3,4,5]) + assert_equal(base_a._data, [3,2,3,4,5]) assert_equal(base_b.dtype, float) - assert_equal(base_b.data, [pi, 2.2, 3.3, 4.4, 5.5]) + assert_equal(base_b._data, [pi, 2.2, 3.3, 4.4, 5.5]) assert_equal(base_c.dtype, '|S8') - assert_equal(base_c.data, ['pi','two','three','four','five']) + assert_equal(base_c._data, ['pi','two','three','four','five']) def test_set_record_slice(self): base = self.data['base'] @@ -2197,13 +2215,13 @@ base[:3] = (pi, pi, 'pi') assert_equal(base_a.dtype, int) - assert_equal(base_a.data, [3,3,3,4,5]) + assert_equal(base_a._data, [3,3,3,4,5]) assert_equal(base_b.dtype, float) - assert_equal(base_b.data, [pi, pi, pi, 4.4, 5.5]) + assert_equal(base_b._data, [pi, pi, pi, 4.4, 5.5]) assert_equal(base_c.dtype, '|S8') - assert_equal(base_c.data, ['pi','pi','pi','four','five']) + assert_equal(base_c._data, ['pi','pi','pi','four','five']) def test_mask_element(self): "Check record access" @@ -2213,7 +2231,7 @@ # for n in ('a','b','c'): assert_equal(base[n].mask, [1,1,0,0,1]) - assert_equal(base[n].data, base.data[n]) + assert_equal(base[n]._data, base._data[n]) ############################################################################### #------------------------------------------------------------------------------ Modified: trunk/numpy/ma/tests/test_mrecords.py =================================================================== --- trunk/numpy/ma/tests/test_mrecords.py 2008-07-21 18:49:45 UTC (rev 5490) +++ trunk/numpy/ma/tests/test_mrecords.py 2008-07-21 18:51:47 UTC (rev 5491) @@ -359,7 +359,7 @@ ddtype = [('a',int),('b',float),('c','|S8')] mrec = fromarrays([_a,_b,_c], dtype=ddtype, fill_value=(99999,99999.,'N/A')) - nrec = recfromarrays((_a.data,_b.data,_c.data), dtype=ddtype) + nrec = recfromarrays((_a._data,_b._data,_c._data), dtype=ddtype) self.data = (mrec, nrec, ddtype) def test_fromarrays(self): Modified: trunk/numpy/ma/tests/test_old_ma.py =================================================================== --- trunk/numpy/ma/tests/test_old_ma.py 2008-07-21 18:49:45 UTC (rev 5490) +++ trunk/numpy/ma/tests/test_old_ma.py 2008-07-21 18:51:47 UTC (rev 5491) @@ -254,8 +254,8 @@ x1 = numpy.arange(5) y1 = array(x1, mask=m) - self.failUnless( y1.data is not x1) - self.failUnless( allequal(x1,y1.data)) + self.failUnless( y1._data is not x1) + self.failUnless( allequal(x1,y1._data)) self.failUnless( y1.mask is m) y1a = array(y1, copy=0) @@ -603,27 +603,27 @@ self.failUnless((-xm).mask) self.failUnless(maximum(xm, xm).mask) self.failUnless(minimum(xm, xm).mask) - self.failUnless(xm.filled().dtype is xm.data.dtype) + self.failUnless(xm.filled().dtype is xm._data.dtype) x = array(0, mask=0) - self.failUnless(x.filled() == x.data) + self.failUnless(x.filled() == x._data) self.failUnlessEqual(str(xm), str(masked_print_option)) def test_testArrayMethods(self): a = array([1,3,2]) b = array([1,3,2], mask=[1,0,1]) - self.failUnless(eq(a.any(), a.data.any())) - self.failUnless(eq(a.all(), a.data.all())) - self.failUnless(eq(a.argmax(), a.data.argmax())) - self.failUnless(eq(a.argmin(), a.data.argmin())) - self.failUnless(eq(a.choose(0,1,2,3,4), a.data.choose(0,1,2,3,4))) - self.failUnless(eq(a.compress([1,0,1]), a.data.compress([1,0,1]))) - self.failUnless(eq(a.conj(), a.data.conj())) - self.failUnless(eq(a.conjugate(), a.data.conjugate())) + self.failUnless(eq(a.any(), a._data.any())) + self.failUnless(eq(a.all(), a._data.all())) + self.failUnless(eq(a.argmax(), a._data.argmax())) + self.failUnless(eq(a.argmin(), a._data.argmin())) + self.failUnless(eq(a.choose(0,1,2,3,4), a._data.choose(0,1,2,3,4))) + self.failUnless(eq(a.compress([1,0,1]), a._data.compress([1,0,1]))) + self.failUnless(eq(a.conj(), a._data.conj())) + self.failUnless(eq(a.conjugate(), a._data.conjugate())) m = array([[1,2],[3,4]]) - self.failUnless(eq(m.diagonal(), m.data.diagonal())) - self.failUnless(eq(a.sum(), a.data.sum())) - self.failUnless(eq(a.take([1,2]), a.data.take([1,2]))) - self.failUnless(eq(m.transpose(), m.data.transpose())) + self.failUnless(eq(m.diagonal(), m._data.diagonal())) + self.failUnless(eq(a.sum(), a._data.sum())) + self.failUnless(eq(a.take([1,2]), a._data.take([1,2]))) + self.failUnless(eq(m.transpose(), m._data.transpose())) def test_testArrayAttributes(self): a = array([1,3,2]) @@ -756,8 +756,8 @@ (x,X,XX,m,mx,mX,mXX,) = self.d clipped = mx.clip(2,8) self.failUnless(eq(clipped.mask,mx.mask)) - self.failUnless(eq(clipped.data,x.clip(2,8))) - self.failUnless(eq(clipped.data,mx.data.clip(2,8))) + self.failUnless(eq(clipped._data,x.clip(2,8))) + self.failUnless(eq(clipped._data,mx._data.clip(2,8))) def test_ptp(self): (x,X,XX,m,mx,mX,mXX,) = self.d @@ -783,16 +783,16 @@ def test_cumprod(self): (x,X,XX,m,mx,mX,mXX,) = self.d mXcp = mX.cumprod(0) - self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(0))) + self.failUnless(eq(mXcp._data,mX.filled(1).cumprod(0))) mXcp = mX.cumprod(1) - self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(1))) + self.failUnless(eq(mXcp._data,mX.filled(1).cumprod(1))) def test_cumsum(self): (x,X,XX,m,mx,mX,mXX,) = self.d mXcp = mX.cumsum(0) - self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(0))) + self.failUnless(eq(mXcp._data,mX.filled(0).cumsum(0))) mXcp = mX.cumsum(1) - self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(1))) + self.failUnless(eq(mXcp._data,mX.filled(0).cumsum(1))) def test_varstd(self): (x,X,XX,m,mx,mX,mXX,) = self.d From numpy-svn at scipy.org Mon Jul 21 15:17:08 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 14:17:08 -0500 (CDT) Subject: [Numpy-svn] r5492 - in branches/1.1.x/numpy/ma: . tests Message-ID: <20080721191708.B73F7C7C00C@scipy.org> Author: pierregm Date: 2008-07-21 14:17:06 -0500 (Mon, 21 Jul 2008) New Revision: 5492 Modified: branches/1.1.x/numpy/ma/core.py branches/1.1.x/numpy/ma/tests/test_core.py Log: core: * Make sure that the .reshape method accepts a new shape as a list (and not as a tuple only) Modified: branches/1.1.x/numpy/ma/core.py =================================================================== --- branches/1.1.x/numpy/ma/core.py 2008-07-21 18:51:47 UTC (rev 5491) +++ branches/1.1.x/numpy/ma/core.py 2008-07-21 19:17:06 UTC (rev 5492) @@ -1867,7 +1867,7 @@ # repeat = _arraymethod('repeat') # - def reshape (self, shape, order='C'): + def reshape (self, *shape, **kwargs): """ Returns a masked array containing the data of a, but with a new shape. The result is a view to the original array; if this is not possible, @@ -1892,11 +1892,12 @@ If you want to modify the shape in place, please use ``a.shape = s`` """ - result = self._data.reshape(shape, order=order).view(type(self)) + kwargs.update({'order':kwargs.get('order','C')}) + result = self._data.reshape(*shape, **kwargs).view(type(self)) result._update_from(self) mask = self._mask if mask is not nomask: - result._mask = mask.reshape(shape, order=order) + result._mask = mask.reshape(*shape, **kwargs) return result # def resize(self, newshape, refcheck=True, order=False): @@ -3426,7 +3427,8 @@ try: return a.reshape(new_shape, order=order) except AttributeError: - return narray(a, copy=False).reshape(new_shape, order=order).view(MaskedArray) + _tmp = narray(a, copy=False).reshape(new_shape, order=order) + return _tmp.view(MaskedArray) def resize(x, new_shape): """Return a new array with the specified shape. Modified: branches/1.1.x/numpy/ma/tests/test_core.py =================================================================== --- branches/1.1.x/numpy/ma/tests/test_core.py 2008-07-21 18:51:47 UTC (rev 5491) +++ branches/1.1.x/numpy/ma/tests/test_core.py 2008-07-21 19:17:06 UTC (rev 5492) @@ -872,10 +872,18 @@ b = a.reshape((5,2)) assert_equal(b.shape, (5,2)) assert(b.flags['C']) + # Try w/ arguments as list instead of tuple + b = a.reshape(5,2) + assert_equal(b.shape, (5,2)) + assert(b.flags['C']) # Try w/ order b = a.reshape((5,2), order='F') assert_equal(b.shape, (5,2)) assert(b.flags['F']) + # Try w/ order + b = a.reshape(5,2, order='F') + assert_equal(b.shape, (5,2)) + assert(b.flags['F']) # c = np.reshape(a, (2,5)) assert(isinstance(c, MaskedArray)) From numpy-svn at scipy.org Mon Jul 21 15:17:11 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 14:17:11 -0500 (CDT) Subject: [Numpy-svn] r5493 - in trunk/numpy/ma: . tests Message-ID: <20080721191711.EED94C7C02C@scipy.org> Author: pierregm Date: 2008-07-21 14:17:09 -0500 (Mon, 21 Jul 2008) New Revision: 5493 Modified: trunk/numpy/ma/core.py trunk/numpy/ma/tests/test_core.py Log: core: * Make sure that the .reshape method accepts a new shape as a list (and not as a tuple only) Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-21 19:17:06 UTC (rev 5492) +++ trunk/numpy/ma/core.py 2008-07-21 19:17:09 UTC (rev 5493) @@ -2038,7 +2038,7 @@ # repeat = _arraymethod('repeat') # - def reshape (self, shape, order='C'): + def reshape (self, *s, **kwargs): """ Returns a masked array containing the data of a, but with a new shape. The result is a view to the original array; if this is not possible, @@ -2063,11 +2063,13 @@ If you want to modify the shape in place, please use ``a.shape = s`` """ - result = self._data.reshape(shape, order=order).view(type(self)) + print "SHAPE: %s" % str(s) + kwargs.update(order=kwargs.get('order','C')) + result = self._data.reshape(*s, **kwargs).view(type(self)) result._update_from(self) mask = self._mask if mask is not nomask: - result._mask = mask.reshape(shape, order=order) + result._mask = mask.reshape(*s, **kwargs) return result # def resize(self, newshape, refcheck=True, order=False): @@ -3626,7 +3628,8 @@ try: return a.reshape(new_shape, order=order) except AttributeError: - return narray(a, copy=False).reshape(new_shape, order=order).view(MaskedArray) + _tmp = narray(a, copy=False).reshape(new_shape, order=order) + return _tmp.view(MaskedArray) def resize(x, new_shape): """Return a new array with the specified shape. Modified: trunk/numpy/ma/tests/test_core.py =================================================================== --- trunk/numpy/ma/tests/test_core.py 2008-07-21 19:17:06 UTC (rev 5492) +++ trunk/numpy/ma/tests/test_core.py 2008-07-21 19:17:09 UTC (rev 5493) @@ -2150,10 +2150,18 @@ b = a.reshape((5,2)) assert_equal(b.shape, (5,2)) assert(b.flags['C']) + # Try w/ arguments as list instead of tuple + b = a.reshape(5,2) + assert_equal(b.shape, (5,2)) + assert(b.flags['C']) # Try w/ order b = a.reshape((5,2), order='F') assert_equal(b.shape, (5,2)) assert(b.flags['F']) + # Try w/ order + b = a.reshape(5,2, order='F') + assert_equal(b.shape, (5,2)) + assert(b.flags['F']) # c = np.reshape(a, (2,5)) assert(isinstance(c, MaskedArray)) From numpy-svn at scipy.org Mon Jul 21 15:19:29 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 14:19:29 -0500 (CDT) Subject: [Numpy-svn] r5494 - trunk/numpy/ma Message-ID: <20080721191929.9858F39C232@scipy.org> Author: pierregm Date: 2008-07-21 14:19:27 -0500 (Mon, 21 Jul 2008) New Revision: 5494 Modified: trunk/numpy/ma/core.py Log: core: * suppressed the debugging info... Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-21 19:17:09 UTC (rev 5493) +++ trunk/numpy/ma/core.py 2008-07-21 19:19:27 UTC (rev 5494) @@ -2063,7 +2063,6 @@ If you want to modify the shape in place, please use ``a.shape = s`` """ - print "SHAPE: %s" % str(s) kwargs.update(order=kwargs.get('order','C')) result = self._data.reshape(*s, **kwargs).view(type(self)) result._update_from(self) From numpy-svn at scipy.org Mon Jul 21 20:49:37 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 21 Jul 2008 19:49:37 -0500 (CDT) Subject: [Numpy-svn] r5495 - in trunk/numpy/lib: . tests Message-ID: <20080722004937.DC5E439C23D@scipy.org> Author: dhuard Date: 2008-07-21 19:49:31 -0500 (Mon, 21 Jul 2008) New Revision: 5495 Modified: trunk/numpy/lib/io.py trunk/numpy/lib/tests/test_io.py Log: Committed patch from Ryan May. It fixes error in loadtxt occurring when usecols is not None and dtypes are given. I added the test suggested by Ryan. Modified: trunk/numpy/lib/io.py =================================================================== --- trunk/numpy/lib/io.py 2008-07-21 19:19:27 UTC (rev 5494) +++ trunk/numpy/lib/io.py 2008-07-22 00:49:31 UTC (rev 5495) @@ -292,8 +292,12 @@ if converters is None: converters = {} if dtype.names is not None: - converterseq = [_getconv(dtype.fields[name][0]) \ - for name in dtype.names] + if usecols is None: + converterseq = [_getconv(dtype.fields[name][0]) \ + for name in dtype.names] + else: + converters.update([(col,_getconv(dtype.fields[name][0])) \ + for col,name in zip(usecols, dtype.names)]) for i,line in enumerate(fh): if i Author: pierregm Date: 2008-07-22 00:22:08 -0500 (Tue, 22 Jul 2008) New Revision: 5496 Modified: branches/1.1.x/numpy/ma/testutils.py Log: define actual_dtype and desired_dtype Modified: branches/1.1.x/numpy/ma/testutils.py =================================================================== --- branches/1.1.x/numpy/ma/testutils.py 2008-07-22 00:49:31 UTC (rev 5495) +++ branches/1.1.x/numpy/ma/testutils.py 2008-07-22 05:22:08 UTC (rev 5496) @@ -104,6 +104,7 @@ raise ValueError(msg) actual = np.array(actual, copy=False, subok=True) desired = np.array(desired, copy=False, subok=True) + (actual_dtype, desired_dtype) = (actual.dtype, desired.dtype) if actual_dtype.char == "S" and desired_dtype.char == "S": return _assert_equal_on_sequences(actual.tolist(), desired.tolist(), From numpy-svn at scipy.org Tue Jul 22 02:37:59 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 01:37:59 -0500 (CDT) Subject: [Numpy-svn] r5497 - in trunk/numpy/lib: . tests Message-ID: <20080722063759.5019EC7C01D@scipy.org> Author: charris Date: 2008-07-22 01:37:48 -0500 (Tue, 22 Jul 2008) New Revision: 5497 Modified: trunk/numpy/lib/io.py trunk/numpy/lib/tests/test_io.py Log: Apply Stefan's patch for Ryan's loadtext fix. Modified: trunk/numpy/lib/io.py =================================================================== --- trunk/numpy/lib/io.py 2008-07-22 05:22:08 UTC (rev 5496) +++ trunk/numpy/lib/io.py 2008-07-22 06:37:48 UTC (rev 5497) @@ -10,6 +10,7 @@ import cStringIO import tempfile import os +import itertools from cPickle import load as _cload, loads from _datasource import DataSource @@ -286,46 +287,89 @@ raise ValueError('fname must be a string or file handle') X = [] + def flatten_dtype(dt): + """Unpack a structured data-type.""" + if dt.names is None: + return [dt] + else: + types = [] + for field in dt.names: + tp, bytes = dt.fields[field] + flat_dt = flatten_dtype(tp) + types.extend(flat_dt) + return types + + def split_line(line): + """Chop off comments, strip, and split at delimiter.""" + line = line.split(comments)[0].strip() + if line: + return line.split(delimiter) + else: + return [] + + # Make sure we're dealing with a proper dtype dtype = np.dtype(dtype) defconv = _getconv(dtype) - converterseq = None - if converters is None: - converters = {} - if dtype.names is not None: - if usecols is None: - converterseq = [_getconv(dtype.fields[name][0]) \ - for name in dtype.names] - else: - converters.update([(col,_getconv(dtype.fields[name][0])) \ - for col,name in zip(usecols, dtype.names)]) - for i,line in enumerate(fh): - if i 1: + # We're dealing with a structured array, each field of + # the dtype matches a column + converterseq = [_getconv(dt) for dt in dtype_types] + else: + # All fields have the same dtype + converterseq = [defconv for i in xrange(N)] + + # By preference, use the converters specified by the user + for i, conv in (converters or {}).iteritems(): + if usecols: + i = usecols.find(i) + converterseq[i] = conv + + # Parse each line, including the first + for i, line in enumerate(itertools.chain([first_line], fh)): + vals = split_line(line) + if len(vals) == 0: + continue + + if usecols: + vals = [vals[i] for i in usecols] + + # Convert each value according to its column and store + X.append(tuple(conv(val) for (conv, val) in zip(converterseq, vals))) + + if len(dtype_types) > 1: + # We're dealing with a structured array, with a dtype such as + # [('x', int), ('y', [('s', int), ('t', float)])] + # + # First, create the array using a flattened dtype: + # [('x', int), ('s', int), ('t', float)] + # + # Then, view the array using the specified dtype. + X = np.array(X, dtype=np.dtype([('', t) for t in dtype_types])) + X = X.view(dtype) + else: + X = np.array(X, dtype) + X = np.squeeze(X) - if unpack: return X.T - else: return X + if unpack: + return X.T + else: + return X - def savetxt(fname, X, fmt='%.18e',delimiter=' '): """ Save the data in X to file fname using fmt string to convert the Modified: trunk/numpy/lib/tests/test_io.py =================================================================== --- trunk/numpy/lib/tests/test_io.py 2008-07-22 05:22:08 UTC (rev 5496) +++ trunk/numpy/lib/tests/test_io.py 2008-07-22 06:37:48 UTC (rev 5497) @@ -232,7 +232,16 @@ assert_equal(arr['stid'], ["JOE", "BOB"]) assert_equal(arr['temp'], [25.3, 27.9]) + def test_fancy_dtype(self): + c = StringIO.StringIO() + c.write('1,2,3.0\n4,5,6.0\n') + c.seek(0) + dt = np.dtype([('x', int), ('y', [('t', int), ('s', float)])]) + x = np.loadtxt(c, dtype=dt, delimiter=',') + a = np.array([(1,(2,3.0)),(4,(5,6.0))], dt) + assert_array_equal(x, a) + class Testfromregex(TestCase): def test_record(self): c = StringIO.StringIO() From numpy-svn at scipy.org Tue Jul 22 11:12:36 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 10:12:36 -0500 (CDT) Subject: [Numpy-svn] r5498 - trunk/numpy/lib Message-ID: <20080722151236.A7DF239C04C@scipy.org> Author: stefan Date: 2008-07-22 10:12:12 -0500 (Tue, 22 Jul 2008) New Revision: 5498 Modified: trunk/numpy/lib/io.py Log: Clean up loadtxt. Fix Python 2.3 compatibility. Modified: trunk/numpy/lib/io.py =================================================================== --- trunk/numpy/lib/io.py 2008-07-22 06:37:48 UTC (rev 5497) +++ trunk/numpy/lib/io.py 2008-07-22 15:12:12 UTC (rev 5498) @@ -274,6 +274,7 @@ SeeAlso: scipy.io.loadmat to read and write matfiles. """ + user_converters = converters if _string_like(fname): if fname.endswith('.gz'): @@ -317,26 +318,26 @@ # Read until we find a line with some values, and use # it to estimate the number of columns, N. - read_line = None - while not read_line: + first_vals = None + while not first_vals: first_line = fh.readline() - read_line = split_line(first_line) - N = len(usecols or read_line) + first_vals = split_line(first_line) + N = len(usecols or first_vals) dtype_types = flatten_dtype(dtype) if len(dtype_types) > 1: # We're dealing with a structured array, each field of # the dtype matches a column - converterseq = [_getconv(dt) for dt in dtype_types] + converters = [_getconv(dt) for dt in dtype_types] else: # All fields have the same dtype - converterseq = [defconv for i in xrange(N)] + converters = [defconv for i in xrange(N)] # By preference, use the converters specified by the user - for i, conv in (converters or {}).iteritems(): + for i, conv in (user_converters or {}).iteritems(): if usecols: i = usecols.find(i) - converterseq[i] = conv + converters[i] = conv # Parse each line, including the first for i, line in enumerate(itertools.chain([first_line], fh)): @@ -348,7 +349,7 @@ vals = [vals[i] for i in usecols] # Convert each value according to its column and store - X.append(tuple(conv(val) for (conv, val) in zip(converterseq, vals))) + X.append(tuple([conv(val) for (conv, val) in zip(converters, vals)])) if len(dtype_types) > 1: # We're dealing with a structured array, with a dtype such as From numpy-svn at scipy.org Tue Jul 22 12:37:56 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 11:37:56 -0500 (CDT) Subject: [Numpy-svn] r5499 - branches/1.1.x/numpy/ma Message-ID: <20080722163756.C266F39C107@scipy.org> Author: charris Date: 2008-07-22 11:37:54 -0500 (Tue, 22 Jul 2008) New Revision: 5499 Modified: branches/1.1.x/numpy/ma/mrecords.py Log: Fix Python2.3 incompatibility. Modified: branches/1.1.x/numpy/ma/mrecords.py =================================================================== --- branches/1.1.x/numpy/ma/mrecords.py 2008-07-22 15:12:12 UTC (rev 5498) +++ branches/1.1.x/numpy/ma/mrecords.py 2008-07-22 16:37:54 UTC (rev 5499) @@ -240,9 +240,8 @@ fillval = _check_fill_value(None, ddtype) # We can't use ddtype to reconstruct the array as we don't need... # ... the shape of the fields - self._fill_value = np.array(tuple(fillval), - dtype=zip(ddtype.names, - (_[1] for _ in ddtype.descr))) + dt = zip(ddtype.names, [s[1] for s in ddtype.descr]) + self._fill_value = np.array(tuple(fillval), dtype=dt) return self._fill_value def set_fill_value(self, value=None): @@ -796,7 +795,7 @@ ############################################################################### if __name__ == '__main__': from numpy.ma.testutils import assert_equal - + if 1: ilist = [1,2,3,4,5] flist = [1.1,2.2,3.3,4.4,5.5] @@ -805,4 +804,4 @@ mask = [0,1,0,0,1] base = ma.array(zip(ilist,flist,slist), mask=mask, dtype=ddtype) mbase = base.view(mrecarray) - mbase._mask = nomask \ No newline at end of file + mbase._mask = nomask From numpy-svn at scipy.org Tue Jul 22 12:40:26 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 11:40:26 -0500 (CDT) Subject: [Numpy-svn] r5500 - branches/1.1.x/numpy/lib Message-ID: <20080722164026.6596639C107@scipy.org> Author: charris Date: 2008-07-22 11:40:24 -0500 (Tue, 22 Jul 2008) New Revision: 5500 Modified: branches/1.1.x/numpy/lib/io.py Log: Backport r5498 fixes to loadtxt. Modified: branches/1.1.x/numpy/lib/io.py =================================================================== --- branches/1.1.x/numpy/lib/io.py 2008-07-22 16:37:54 UTC (rev 5499) +++ branches/1.1.x/numpy/lib/io.py 2008-07-22 16:40:24 UTC (rev 5500) @@ -10,6 +10,7 @@ import cStringIO import tempfile import os +import itertools from cPickle import load as _cload, loads from _datasource import DataSource @@ -273,6 +274,7 @@ SeeAlso: scipy.io.loadmat to read and write matfiles. """ + user_converters = converters if _string_like(fname): if fname.endswith('.gz'): @@ -286,42 +288,89 @@ raise ValueError('fname must be a string or file handle') X = [] + def flatten_dtype(dt): + """Unpack a structured data-type.""" + if dt.names is None: + return [dt] + else: + types = [] + for field in dt.names: + tp, bytes = dt.fields[field] + flat_dt = flatten_dtype(tp) + types.extend(flat_dt) + return types + + def split_line(line): + """Chop off comments, strip, and split at delimiter.""" + line = line.split(comments)[0].strip() + if line: + return line.split(delimiter) + else: + return [] + + # Make sure we're dealing with a proper dtype dtype = np.dtype(dtype) defconv = _getconv(dtype) - converterseq = None - if converters is None: - converters = {} - if dtype.names is not None: - converterseq = [_getconv(dtype.fields[name][0]) \ - for name in dtype.names] - for i,line in enumerate(fh): - if i 1: + # We're dealing with a structured array, each field of + # the dtype matches a column + converters = [_getconv(dt) for dt in dtype_types] + else: + # All fields have the same dtype + converters = [defconv for i in xrange(N)] + + # By preference, use the converters specified by the user + for i, conv in (user_converters or {}).iteritems(): + if usecols: + i = usecols.find(i) + converters[i] = conv + + # Parse each line, including the first + for i, line in enumerate(itertools.chain([first_line], fh)): + vals = split_line(line) + if len(vals) == 0: + continue + + if usecols: + vals = [vals[i] for i in usecols] + + # Convert each value according to its column and store + X.append(tuple([conv(val) for (conv, val) in zip(converters, vals)])) + + if len(dtype_types) > 1: + # We're dealing with a structured array, with a dtype such as + # [('x', int), ('y', [('s', int), ('t', float)])] + # + # First, create the array using a flattened dtype: + # [('x', int), ('s', int), ('t', float)] + # + # Then, view the array using the specified dtype. + X = np.array(X, dtype=np.dtype([('', t) for t in dtype_types])) + X = X.view(dtype) + else: + X = np.array(X, dtype) + X = np.squeeze(X) - if unpack: return X.T - else: return X + if unpack: + return X.T + else: + return X - def savetxt(fname, X, fmt='%.18e',delimiter=' '): """ Save the data in X to file fname using fmt string to convert the @@ -344,9 +393,9 @@ Examples -------- - >>> savetxt('test.out', x, delimiter=',') # X is an array - >>> savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays - >>> savetxt('test.out', x, fmt='%1.4e') # use exponential notation + >>> np.savetxt('test.out', x, delimiter=',') # X is an array + >>> np.savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays + >>> np.savetxt('test.out', x, fmt='%1.4e') # use exponential notation Notes on fmt ------------ From numpy-svn at scipy.org Tue Jul 22 14:18:47 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 13:18:47 -0500 (CDT) Subject: [Numpy-svn] r5501 - trunk/numpy/lib/tests Message-ID: <20080722181847.DCC8C39C1A6@scipy.org> Author: alan.mcintyre Date: 2008-07-22 13:18:42 -0500 (Tue, 22 Jul 2008) New Revision: 5501 Modified: trunk/numpy/lib/tests/test_arraysetops.py trunk/numpy/lib/tests/test_format.py trunk/numpy/lib/tests/test_function_base.py Log: Added tests to improve coverage of numpy.lib. Modified: trunk/numpy/lib/tests/test_arraysetops.py =================================================================== --- trunk/numpy/lib/tests/test_arraysetops.py 2008-07-22 16:40:24 UTC (rev 5500) +++ trunk/numpy/lib/tests/test_arraysetops.py 2008-07-22 18:18:42 UTC (rev 5501) @@ -14,6 +14,12 @@ c = unique1d( a ) assert_array_equal( c, ec ) + d, c = unique1d( a, True ) + ed = np.array( [2, 3, 0, 1] ) + + assert_array_equal( d,ed ) + assert_array_equal( c, ec ) + assert_array_equal([], unique1d([])) def test_intersect1d( self ): Modified: trunk/numpy/lib/tests/test_format.py =================================================================== --- trunk/numpy/lib/tests/test_format.py 2008-07-22 16:40:24 UTC (rev 5500) +++ trunk/numpy/lib/tests/test_format.py 2008-07-22 18:18:42 UTC (rev 5501) @@ -280,7 +280,7 @@ import tempfile import numpy as np -from numpy.testing import assert_array_equal, raises +from numpy.testing import * from numpy.lib import format @@ -506,6 +506,46 @@ f = StringIO(magic) yield raises(ValueError)(format.read_array), f +def test_bad_magic_args(): + assert_raises(ValueError, format.magic, -1, 1) + assert_raises(ValueError, format.magic, 256, 1) + assert_raises(ValueError, format.magic, 1, -1) + assert_raises(ValueError, format.magic, 1, 256) +def test_large_header(): + s = StringIO() + d = {'a':1,'b':2} + format.write_array_header_1_0(s,d) + + s = StringIO() + d = {'a':1,'b':2,'c':'x'*256*256} + assert_raises(ValueError, format.write_array_header_1_0, s, d) + +def test_bad_header(): + # header of length less than 2 should fail + s = StringIO() + assert_raises(ValueError, format.read_array_header_1_0, s) + s = StringIO('1') + assert_raises(ValueError, format.read_array_header_1_0, s) + + # header shorter than indicated size should fail + s = StringIO('\x01\x00') + assert_raises(ValueError, format.read_array_header_1_0, s) + + # headers without the exact keys required should fail + d = {"shape":(1,2), + "descr":"x"} + s = StringIO() + format.write_array_header_1_0(s,d) + assert_raises(ValueError, format.read_array_header_1_0, s) + + d = {"shape":(1,2), + "fortran_order":False, + "descr":"x", + "extrakey":-1} + s = StringIO() + format.write_array_header_1_0(s,d) + assert_raises(ValueError, format.read_array_header_1_0, s) + if __name__ == "__main__": run_module_suite() Modified: trunk/numpy/lib/tests/test_function_base.py =================================================================== --- trunk/numpy/lib/tests/test_function_base.py 2008-07-22 16:40:24 UTC (rev 5500) +++ trunk/numpy/lib/tests/test_function_base.py 2008-07-22 18:18:42 UTC (rev 5501) @@ -287,6 +287,19 @@ assert_array_equal(diff(x,axis=0),out3) assert_array_equal(diff(x,n=2,axis=0),out4) +class TestGradient(TestCase): + def test_basic(self): + x = array([[1,1],[3,4]]) + dx = [array([[2.,3.],[2.,3.]]), + array([[0.,0.],[1.,1.]])] + assert_array_equal(gradient(x), dx) + + def test_badargs(self): + # for 2D array, gradient can take 0,1, or 2 extra args + x = array([[1,1],[3,4]]) + assert_raises(SyntaxError, gradient, x, array([1.,1.]), + array([1.,1.]), array([1.,1.])) + class TestAngle(TestCase): def test_basic(self): x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j] From numpy-svn at scipy.org Tue Jul 22 15:47:57 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 14:47:57 -0500 (CDT) Subject: [Numpy-svn] r5502 - branches/1.1.x/numpy/f2py Message-ID: <20080722194757.0DB5539C1A6@scipy.org> Author: charris Date: 2008-07-22 14:47:54 -0500 (Tue, 22 Jul 2008) New Revision: 5502 Modified: branches/1.1.x/numpy/f2py/f2py2e.py branches/1.1.x/numpy/f2py/setup.py branches/1.1.x/numpy/f2py/setupscons.py Log: Backport r5357: f2py removal part 1. Modified: branches/1.1.x/numpy/f2py/f2py2e.py =================================================================== --- branches/1.1.x/numpy/f2py/f2py2e.py 2008-07-22 18:18:42 UTC (rev 5501) +++ branches/1.1.x/numpy/f2py/f2py2e.py 2008-07-22 19:47:54 UTC (rev 5502) @@ -69,11 +69,11 @@ Options: - --g3-numpy Use numpy.f2py.lib tool, the 3rd generation of F2PY, - with NumPy support. --2d-numpy Use numpy.f2py tool with NumPy support. [DEFAULT] --2d-numeric Use f2py2e tool with Numeric support. --2d-numarray Use f2py2e tool with Numarray support. + --g3-numpy Use 3rd generation f2py from the separate f2py package. + [NOT AVAILABLE YET] -h Write signatures of the fortran routines to file and exit. You can then edit and use it instead Modified: branches/1.1.x/numpy/f2py/setup.py =================================================================== --- branches/1.1.x/numpy/f2py/setup.py 2008-07-22 18:18:42 UTC (rev 5501) +++ branches/1.1.x/numpy/f2py/setup.py 2008-07-22 19:47:54 UTC (rev 5502) @@ -63,10 +63,8 @@ except ValueError: pass os.environ["NO_SCIPY_IMPORT"]="f2py" if mode=="g3-numpy": - try: - from main import main - except ImportError: - from numpy.f2py.lib.api import main + print >> sys.stderr, "G3 f2py support is not implemented, yet." + sys.exit(1) elif mode=="2e-numeric": from f2py2e import main elif mode=="2e-numarray": Modified: branches/1.1.x/numpy/f2py/setupscons.py =================================================================== --- branches/1.1.x/numpy/f2py/setupscons.py 2008-07-22 18:18:42 UTC (rev 5501) +++ branches/1.1.x/numpy/f2py/setupscons.py 2008-07-22 19:47:54 UTC (rev 5502) @@ -61,10 +61,8 @@ except ValueError: pass os.environ["NO_SCIPY_IMPORT"]="f2py" if mode=="g3-numpy": - try: - from main import main - except ImportError: - from numpy.f2py.lib.api import main + print >> sys.stderr, "G3 f2py support is not implemented, yet." + sys.exit(1) elif mode=="2e-numeric": from f2py2e import main elif mode=="2e-numarray": From numpy-svn at scipy.org Tue Jul 22 15:52:42 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 14:52:42 -0500 (CDT) Subject: [Numpy-svn] r5503 - trunk/numpy/core/tests Message-ID: <20080722195242.48CE239C300@scipy.org> Author: ptvirtan Date: 2008-07-22 14:52:34 -0500 (Tue, 22 Jul 2008) New Revision: 5503 Modified: trunk/numpy/core/tests/test_umath.py Log: Skip one more possibly failing C99 test Modified: trunk/numpy/core/tests/test_umath.py =================================================================== --- trunk/numpy/core/tests/test_umath.py 2008-07-22 19:47:54 UTC (rev 5502) +++ trunk/numpy/core/tests/test_umath.py 2008-07-22 19:52:34 UTC (rev 5503) @@ -278,7 +278,7 @@ def test_clog(self): for p, v, e in [ ((-0., 0.), (-inf, pi), 'divide'), - ((+0., 0.), (-inf, 0.), 'divide'), + ((+0., 0.), (-inf, 0.), 'XXX divide'), # fails on OSX? ((1., inf), (inf, pi/2), ''), ((1., nan), (nan, nan), 'invalid-optional'), ((-inf, 1.), (inf, pi), ''), From numpy-svn at scipy.org Tue Jul 22 15:57:16 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 14:57:16 -0500 (CDT) Subject: [Numpy-svn] r5504 - branches/1.1.x/numpy/f2py Message-ID: <20080722195716.399CC39C718@scipy.org> Author: charris Date: 2008-07-22 14:57:13 -0500 (Tue, 22 Jul 2008) New Revision: 5504 Modified: branches/1.1.x/numpy/f2py/setup.py Log: Backport r5348: f2py removal part 2. Modified: branches/1.1.x/numpy/f2py/setup.py =================================================================== --- branches/1.1.x/numpy/f2py/setup.py 2008-07-22 19:52:34 UTC (rev 5503) +++ branches/1.1.x/numpy/f2py/setup.py 2008-07-22 19:57:13 UTC (rev 5504) @@ -30,8 +30,6 @@ def configuration(parent_package='',top_path=None): config = Configuration('f2py', parent_package, top_path) - config.add_subpackage('lib') - config.add_data_dir('docs') config.add_data_files('src/fortranobject.c', From numpy-svn at scipy.org Tue Jul 22 16:37:15 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 15:37:15 -0500 (CDT) Subject: [Numpy-svn] r5505 - branches/1.1.x/numpy/tests Message-ID: <20080722203715.E352839C643@scipy.org> Author: charris Date: 2008-07-22 15:37:12 -0500 (Tue, 22 Jul 2008) New Revision: 5505 Modified: branches/1.1.x/numpy/tests/test_ctypeslib.py Log: Make skip message a simple 'S'. Modified: branches/1.1.x/numpy/tests/test_ctypeslib.py =================================================================== --- branches/1.1.x/numpy/tests/test_ctypeslib.py 2008-07-22 19:57:13 UTC (rev 5504) +++ branches/1.1.x/numpy/tests/test_ctypeslib.py 2008-07-22 20:37:12 UTC (rev 5505) @@ -1,6 +1,7 @@ import numpy as np from numpy.ctypeslib import ndpointer, load_library from numpy.testing import * +import sys class TestLoadLibrary(NumpyTestCase): def check_basic(self): @@ -8,9 +9,8 @@ cdll = load_library('multiarray', np.core.multiarray.__file__) except ImportError, e: - msg = "ctypes is not available on this python: skipping the test" \ - " (import error was: %s)" % str(e) - print msg + sys.stdout.write('S') + sys.stdout.flush() def check_basic2(self): """Regression for #801: load_library with a full library name @@ -22,11 +22,11 @@ cdll = load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: - print "No distutils available, skipping test." + sys.stdout.write('S') + sys.stdout.flush() except ImportError, e: - msg = "ctypes is not available on this python: skipping the test" \ - " (import error was: %s)" % str(e) - print msg + sys.stdout.write('S') + sys.stdout.flush() class TestNdpointer(NumpyTestCase): def check_dtype(self): From numpy-svn at scipy.org Tue Jul 22 16:52:51 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 15:52:51 -0500 (CDT) Subject: [Numpy-svn] r5506 - in trunk/numpy/ma: . tests Message-ID: <20080722205251.DFCDC39C701@scipy.org> Author: pierregm Date: 2008-07-22 15:52:48 -0500 (Tue, 22 Jul 2008) New Revision: 5506 Modified: trunk/numpy/ma/core.py trunk/numpy/ma/tests/test_core.py Log: * force the domain to the shape of the other element in DomainedBinaryOperation (bugfix 857) Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-22 20:37:12 UTC (rev 5505) +++ trunk/numpy/ma/core.py 2008-07-22 20:52:48 UTC (rev 5506) @@ -639,7 +639,10 @@ if t.any(None): mb = mask_or(mb, t) # The following line controls the domain filling - d2 = np.where(t,self.filly,d2) + if t.size == d2.size: + d2 = np.where(t,self.filly,d2) + else: + d2 = np.where(np.resize(t, d2.shape),self.filly, d2) m = mask_or(ma, mb) if (not m.ndim) and m: return masked Modified: trunk/numpy/ma/tests/test_core.py =================================================================== --- trunk/numpy/ma/tests/test_core.py 2008-07-22 20:37:12 UTC (rev 5505) +++ trunk/numpy/ma/tests/test_core.py 2008-07-22 20:52:48 UTC (rev 5506) @@ -492,6 +492,25 @@ assert_equal(np.multiply(x,y), multiply(xm, ym)) assert_equal(np.divide(x,y), divide(xm, ym)) + def test_divide_on_different_shapes(self): + x = arange(6, dtype=float) + x.shape = (2,3) + y = arange(3, dtype=float) + # + z = x/y + assert_equal(z, [[-1.,1.,1.], [-1.,4.,2.5]]) + assert_equal(z.mask, [[1,0,0],[1,0,0]]) + # + z = x/y[None,:] + assert_equal(z, [[-1.,1.,1.], [-1.,4.,2.5]]) + assert_equal(z.mask, [[1,0,0],[1,0,0]]) + # + y = arange(2, dtype=float) + z = x/y[:,None] + assert_equal(z, [[-1.,-1.,-1.], [3.,4.,5.]]) + assert_equal(z.mask, [[1,1,1],[0,0,0]]) + + def test_mixed_arithmetic(self): "Tests mixed arithmetics." na = np.array([1]) From numpy-svn at scipy.org Tue Jul 22 16:56:49 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 15:56:49 -0500 (CDT) Subject: [Numpy-svn] r5507 - in branches/1.1.x/numpy/ma: . tests Message-ID: <20080722205649.3F78439C55F@scipy.org> Author: pierregm Date: 2008-07-22 15:56:27 -0500 (Tue, 22 Jul 2008) New Revision: 5507 Modified: branches/1.1.x/numpy/ma/core.py branches/1.1.x/numpy/ma/tests/test_core.py Log: * force the domain to the shape of the other element in DomainedBinaryOperation (bugfix 857) Modified: branches/1.1.x/numpy/ma/core.py =================================================================== --- branches/1.1.x/numpy/ma/core.py 2008-07-22 20:52:48 UTC (rev 5506) +++ branches/1.1.x/numpy/ma/core.py 2008-07-22 20:56:27 UTC (rev 5507) @@ -626,7 +626,10 @@ if t.any(None): mb = mask_or(mb, t) # The following line controls the domain filling - d2 = np.where(t,self.filly,d2) + if t.size == d2.size: + d2 = np.where(t,self.filly,d2) + else: + d2 = np.where(np.resize(t, d2.shape),self.filly, d2) m = mask_or(ma, mb) if (not m.ndim) and m: return masked Modified: branches/1.1.x/numpy/ma/tests/test_core.py =================================================================== --- branches/1.1.x/numpy/ma/tests/test_core.py 2008-07-22 20:52:48 UTC (rev 5506) +++ branches/1.1.x/numpy/ma/tests/test_core.py 2008-07-22 20:56:27 UTC (rev 5507) @@ -1609,7 +1609,26 @@ assert_almost_equal(x._data,y._data) + def test_divide_on_different_shapes(self): + x = arange(6, dtype=float) + x.shape = (2,3) + y = arange(3, dtype=float) + # + z = x/y + assert_equal(z, [[-1.,1.,1.], [-1.,4.,2.5]]) + assert_equal(z.mask, [[1,0,0],[1,0,0]]) + # + z = x/y[None,:] + assert_equal(z, [[-1.,1.,1.], [-1.,4.,2.5]]) + assert_equal(z.mask, [[1,0,0],[1,0,0]]) + # + y = arange(2, dtype=float) + z = x/y[:,None] + assert_equal(z, [[-1.,-1.,-1.], [3.,4.,5.]]) + assert_equal(z.mask, [[1,1,1],[0,0,0]]) + + ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": From numpy-svn at scipy.org Tue Jul 22 19:02:34 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 22 Jul 2008 18:02:34 -0500 (CDT) Subject: [Numpy-svn] r5508 - in trunk/numpy: ma/tests testing/tests Message-ID: <20080722230234.1954C39C643@scipy.org> Author: alan.mcintyre Date: 2008-07-22 18:02:29 -0500 (Tue, 22 Jul 2008) New Revision: 5508 Modified: trunk/numpy/ma/tests/test_subclassing.py trunk/numpy/testing/tests/test_utils.py Log: Standardize NumPy import as "import numpy as np". Modified: trunk/numpy/ma/tests/test_subclassing.py =================================================================== --- trunk/numpy/ma/tests/test_subclassing.py 2008-07-22 20:56:27 UTC (rev 5507) +++ trunk/numpy/ma/tests/test_subclassing.py 2008-07-22 23:02:29 UTC (rev 5508) @@ -10,25 +10,25 @@ __revision__ = "$Revision: 3473 $" __date__ = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $' -import numpy as N +import numpy as np import numpy.core.numeric as numeric from numpy.testing import * from numpy.ma.testutils import * from numpy.ma.core import * -class SubArray(N.ndarray): - """Defines a generic N.ndarray subclass, that stores some metadata +class SubArray(np.ndarray): + """Defines a generic np.ndarray subclass, that stores some metadata in the dictionary `info`.""" def __new__(cls,arr,info={}): - x = N.asanyarray(arr).view(cls) + x = np.asanyarray(arr).view(cls) x.info = info return x def __array_finalize__(self, obj): self.info = getattr(obj,'info',{}) return def __add__(self, other): - result = N.ndarray.__add__(self, other) + result = np.ndarray.__add__(self, other) result.info.update({'added':result.info.pop('added',0)+1}) return result @@ -52,13 +52,13 @@ msubarray = MSubArray -class MMatrix(MaskedArray, N.matrix,): +class MMatrix(MaskedArray, np.matrix,): def __new__(cls, data, mask=nomask): - mat = N.matrix(data) + mat = np.matrix(data) _data = MaskedArray.__new__(cls, data=mat, mask=mask) return _data def __array_finalize__(self,obj): - N.matrix.__array_finalize__(self, obj) + np.matrix.__array_finalize__(self, obj) MaskedArray.__array_finalize__(self,obj) return def _get_series(self): @@ -74,7 +74,7 @@ def test_data_subclassing(self): "Tests whether the subclass is kept." - x = N.arange(5) + x = np.arange(5) m = [0,0,1,0,0] xsub = SubArray(x) xmsub = masked_array(xsub, mask=m) @@ -84,14 +84,14 @@ def test_maskedarray_subclassing(self): "Tests subclassing MaskedArray" - x = N.arange(5) + x = np.arange(5) mx = mmatrix(x,mask=[0,1,0,0,0]) - assert isinstance(mx._data, N.matrix) + assert isinstance(mx._data, np.matrix) "Tests masked_unary_operation" assert isinstance(add(mx,mx), mmatrix) assert isinstance(add(mx,x), mmatrix) assert_equal(add(mx,x), mx+x) - assert isinstance(add(mx,mx)._data, N.matrix) + assert isinstance(add(mx,mx)._data, np.matrix) assert isinstance(add.outer(mx,mx), mmatrix) "Tests masked_binary_operation" assert isinstance(hypot(mx,mx), mmatrix) @@ -126,7 +126,7 @@ def test_subclasspreservation(self): "Checks that masked_array(...,subok=True) preserves the class." - x = N.arange(5) + x = np.arange(5) m = [0,0,1,0,0] xinfo = [(i,j) for (i,j) in zip(x,m)] xsub = MSubArray(x, mask=m, info={'xsub':xinfo}) Modified: trunk/numpy/testing/tests/test_utils.py =================================================================== --- trunk/numpy/testing/tests/test_utils.py 2008-07-22 20:56:27 UTC (rev 5507) +++ trunk/numpy/testing/tests/test_utils.py 2008-07-22 23:02:29 UTC (rev 5508) @@ -1,4 +1,4 @@ -import numpy as N +import numpy as np from numpy.testing import * import unittest @@ -19,29 +19,29 @@ def test_array_rank1_eq(self): """Test two equal array of rank 1 are found equal.""" - a = N.array([1, 2]) - b = N.array([1, 2]) + a = np.array([1, 2]) + b = np.array([1, 2]) self._test_equal(a, b) def test_array_rank1_noteq(self): """Test two different array of rank 1 are found not equal.""" - a = N.array([1, 2]) - b = N.array([2, 2]) + a = np.array([1, 2]) + b = np.array([2, 2]) self._test_not_equal(a, b) def test_array_rank2_eq(self): """Test two equal array of rank 2 are found equal.""" - a = N.array([[1, 2], [3, 4]]) - b = N.array([[1, 2], [3, 4]]) + a = np.array([[1, 2], [3, 4]]) + b = np.array([[1, 2], [3, 4]]) self._test_equal(a, b) def test_array_diffshape(self): """Test two arrays with different shapes are found not equal.""" - a = N.array([1, 2]) - b = N.array([[1, 2], [1, 2]]) + a = np.array([1, 2]) + b = np.array([[1, 2], [1, 2]]) self._test_not_equal(a, b) @@ -52,7 +52,7 @@ def test_generic_rank1(self): """Test rank 1 array for all dtypes.""" def foo(t): - a = N.empty(2, t) + a = np.empty(2, t) a.fill(1) b = a.copy() c = a.copy() @@ -71,7 +71,7 @@ def test_generic_rank3(self): """Test rank 3 array for all dtypes.""" def foo(t): - a = N.empty((4, 2, 3), t) + a = np.empty((4, 2, 3), t) a.fill(1) b = a.copy() c = a.copy() @@ -89,35 +89,35 @@ def test_nan_array(self): """Test arrays with nan values in them.""" - a = N.array([1, 2, N.nan]) - b = N.array([1, 2, N.nan]) + a = np.array([1, 2, np.nan]) + b = np.array([1, 2, np.nan]) self._test_equal(a, b) - c = N.array([1, 2, 3]) + c = np.array([1, 2, 3]) self._test_not_equal(c, b) def test_string_arrays(self): """Test two arrays with different shapes are found not equal.""" - a = N.array(['floupi', 'floupa']) - b = N.array(['floupi', 'floupa']) + a = np.array(['floupi', 'floupa']) + b = np.array(['floupi', 'floupa']) self._test_equal(a, b) - c = N.array(['floupipi', 'floupa']) + c = np.array(['floupipi', 'floupa']) self._test_not_equal(c, b) def test_recarrays(self): """Test record arrays.""" - a = N.empty(2, [('floupi', N.float), ('floupa', N.float)]) + a = np.empty(2, [('floupi', np.float), ('floupa', np.float)]) a['floupi'] = [1, 2] a['floupa'] = [1, 2] b = a.copy() self._test_equal(a, b) - c = N.empty(2, [('floupipi', N.float), ('floupa', N.float)]) + c = np.empty(2, [('floupipi', np.float), ('floupa', np.float)]) c['floupipi'] = a['floupi'].copy() c['floupa'] = a['floupa'].copy() From numpy-svn at scipy.org Wed Jul 23 09:17:48 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 23 Jul 2008 08:17:48 -0500 (CDT) Subject: [Numpy-svn] r5509 - trunk/numpy/linalg Message-ID: <20080723131748.079E539C685@scipy.org> Author: alan.mcintyre Date: 2008-07-23 08:17:45 -0500 (Wed, 23 Jul 2008) New Revision: 5509 Modified: trunk/numpy/linalg/linalg.py Log: Removed unused private function _castCopyAndTranspose. Modified: trunk/numpy/linalg/linalg.py =================================================================== --- trunk/numpy/linalg/linalg.py 2008-07-22 23:02:29 UTC (rev 5508) +++ trunk/numpy/linalg/linalg.py 2008-07-23 13:17:45 UTC (rev 5509) @@ -92,15 +92,8 @@ t = double return t, result_type -def _castCopyAndTranspose(type, *arrays): - if len(arrays) == 1: - return transpose(arrays[0]).astype(type) - else: - return [transpose(a).astype(type) for a in arrays] +# _fastCopyAndTranpose assumes the input is 2D (as all the calls in here are). -# _fastCopyAndTranpose is an optimized version of _castCopyAndTranspose. -# It assumes the input is 2D (as all the calls in here are). - _fastCT = fastCopyAndTranspose def _fastCopyAndTranspose(type, *arrays): From numpy-svn at scipy.org Wed Jul 23 09:23:54 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 23 Jul 2008 08:23:54 -0500 (CDT) Subject: [Numpy-svn] r5510 - trunk/numpy/lib Message-ID: <20080723132354.43B5A39C7D8@scipy.org> Author: alan.mcintyre Date: 2008-07-23 08:23:52 -0500 (Wed, 23 Jul 2008) New Revision: 5510 Modified: trunk/numpy/lib/io.py Log: Fix doctest command continuation line. Modified: trunk/numpy/lib/io.py =================================================================== --- trunk/numpy/lib/io.py 2008-07-23 13:17:45 UTC (rev 5509) +++ trunk/numpy/lib/io.py 2008-07-23 13:23:52 UTC (rev 5510) @@ -270,7 +270,7 @@ >>> X = loadtxt('test.dat') # data in two columns >>> x,y,z = load('somefile.dat', usecols=(3,5,7), unpack=True) >>> r = np.loadtxt('record.dat', dtype={'names':('gender','age','weight'), - 'formats': ('S1','i4', 'f4')}) + ... 'formats': ('S1','i4', 'f4')}) SeeAlso: scipy.io.loadmat to read and write matfiles. """ From numpy-svn at scipy.org Wed Jul 23 09:51:48 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 23 Jul 2008 08:51:48 -0500 (CDT) Subject: [Numpy-svn] r5511 - in trunk/numpy/lib: . benchmarks Message-ID: <20080723135148.7830239C57A@scipy.org> Author: alan.mcintyre Date: 2008-07-23 08:51:45 -0500 (Wed, 23 Jul 2008) New Revision: 5511 Added: trunk/numpy/lib/benchmarks/ trunk/numpy/lib/benchmarks/bench_arraysetops.py Modified: trunk/numpy/lib/arraysetops.py Log: Standardized NumPy import as "import numpy as np". Moved unique1d benchmarking code to new benchmarks directory. Modified: trunk/numpy/lib/arraysetops.py =================================================================== --- trunk/numpy/lib/arraysetops.py 2008-07-23 13:23:52 UTC (rev 5510) +++ trunk/numpy/lib/arraysetops.py 2008-07-23 13:51:45 UTC (rev 5511) @@ -36,7 +36,7 @@ 'setmember1d', 'union1d', 'setdiff1d'] import time -import numpy as nm +import numpy as np def ediff1d(ary, to_end=None, to_begin=None): """The differences between consecutive elements of an array, possibly with @@ -59,7 +59,7 @@ The differences. Loosely, this will be (ary[1:] - ary[:-1]). """ - ary = nm.asarray(ary).flat + ary = np.asarray(ary).flat ed = ary[1:] - ary[:-1] arrays = [ed] if to_begin is not None: @@ -70,7 +70,7 @@ if len(arrays) != 1: # We'll save ourselves a copy of a potentially large array in the common # case where neither to_begin or to_end was given. - ed = nm.hstack(arrays) + ed = np.hstack(arrays) return ed @@ -101,20 +101,20 @@ for performing set operations on arrays. """ - ar = nm.asarray(ar1).flatten() + ar = np.asarray(ar1).flatten() if ar.size == 0: - if return_index: return nm.empty(0, nm.bool), ar + if return_index: return np.empty(0, np.bool), ar else: return ar if return_index: perm = ar.argsort() aux = ar[perm] - flag = nm.concatenate( ([True], aux[1:] != aux[:-1]) ) + flag = np.concatenate( ([True], aux[1:] != aux[:-1]) ) return perm[flag], aux[flag] else: ar.sort() - flag = nm.concatenate( ([True], ar[1:] != ar[:-1]) ) + flag = np.concatenate( ([True], ar[1:] != ar[:-1]) ) return ar[flag] def intersect1d(ar1, ar2): @@ -139,7 +139,7 @@ performing set operations on arrays. """ - aux = nm.concatenate((ar1,ar2)) + aux = np.concatenate((ar1,ar2)) aux.sort() return aux[aux[1:] == aux[:-1]] @@ -164,7 +164,7 @@ """ # Might be faster than unique1d( intersect1d( ar1, ar2 ) )? - aux = nm.concatenate((unique1d(ar1), unique1d(ar2))) + aux = np.concatenate((unique1d(ar1), unique1d(ar2))) aux.sort() return aux[aux[1:] == aux[:-1]] @@ -190,13 +190,13 @@ performing set operations on arrays. """ - aux = nm.concatenate((ar1, ar2)) + aux = np.concatenate((ar1, ar2)) if aux.size == 0: return aux aux.sort() # flag = ediff1d( aux, to_end = 1, to_begin = 1 ) == 0 - flag = nm.concatenate( ([True], aux[1:] != aux[:-1], [True] ) ) + flag = np.concatenate( ([True], aux[1:] != aux[:-1], [True] ) ) # flag2 = ediff1d( flag ) == 0 flag2 = flag[1:] == flag[:-1] return aux[flag2] @@ -224,12 +224,12 @@ performing set operations on arrays. """ - ar1 = nm.asarray( ar1 ) - ar2 = nm.asarray( ar2 ) - ar = nm.concatenate( (ar1, ar2 ) ) - b1 = nm.zeros( ar1.shape, dtype = nm.int8 ) - b2 = nm.ones( ar2.shape, dtype = nm.int8 ) - tt = nm.concatenate( (b1, b2) ) + ar1 = np.asarray( ar1 ) + ar2 = np.asarray( ar2 ) + ar = np.concatenate( (ar1, ar2 ) ) + b1 = np.zeros( ar1.shape, dtype = np.int8 ) + b2 = np.ones( ar2.shape, dtype = np.int8 ) + tt = np.concatenate( (b1, b2) ) # We need this to be a stable sort, so always use 'mergesort' here. The # values from the first array should always come before the values from the @@ -238,8 +238,8 @@ aux = ar[perm] aux2 = tt[perm] # flag = ediff1d( aux, 1 ) == 0 - flag = nm.concatenate( (aux[1:] == aux[:-1], [False] ) ) - ii = nm.where( flag * aux2 )[0] + flag = np.concatenate( (aux[1:] == aux[:-1], [False] ) ) + ii = np.where( flag * aux2 )[0] aux = perm[ii+1] perm[ii+1] = perm[ii] perm[ii] = aux @@ -270,7 +270,7 @@ performing set operations on arrays. """ - return unique1d( nm.concatenate( (ar1, ar2) ) ) + return unique1d( np.concatenate( (ar1, ar2) ) ) def setdiff1d(ar1, ar2): """Set difference of 1D arrays with unique elements. @@ -298,67 +298,5 @@ if aux.size == 0: return aux else: - return nm.asarray(ar1)[aux == 0] + return np.asarray(ar1)[aux == 0] -def _test_unique1d_speed( plot_results = False ): -# exponents = nm.linspace( 2, 7, 9 ) - exponents = nm.linspace( 2, 7, 9 ) - ratios = [] - nItems = [] - dt1s = [] - dt2s = [] - for ii in exponents: - - nItem = 10 ** ii - print 'using %d items:' % nItem - a = nm.fix( nItem / 10 * nm.random.random( nItem ) ) - - print 'unique:' - tt = time.clock() - b = nm.unique( a ) - dt1 = time.clock() - tt - print dt1 - - print 'unique1d:' - tt = time.clock() - c = unique1d( a ) - dt2 = time.clock() - tt - print dt2 - - - if dt1 < 1e-8: - ratio = 'ND' - else: - ratio = dt2 / dt1 - print 'ratio:', ratio - print 'nUnique: %d == %d\n' % (len( b ), len( c )) - - nItems.append( nItem ) - ratios.append( ratio ) - dt1s.append( dt1 ) - dt2s.append( dt2 ) - - assert nm.alltrue( b == c ) - - print nItems - print dt1s - print dt2s - print ratios - - if plot_results: - import pylab - - def plotMe( fig, fun, nItems, dt1s, dt2s ): - pylab.figure( fig ) - fun( nItems, dt1s, 'g-o', linewidth = 2, markersize = 8 ) - fun( nItems, dt2s, 'b-x', linewidth = 2, markersize = 8 ) - pylab.legend( ('unique', 'unique1d' ) ) - pylab.xlabel( 'nItem' ) - pylab.ylabel( 'time [s]' ) - - plotMe( 1, pylab.loglog, nItems, dt1s, dt2s ) - plotMe( 2, pylab.plot, nItems, dt1s, dt2s ) - pylab.show() - -if (__name__ == '__main__'): - _test_unique1d_speed( plot_results = True ) Added: trunk/numpy/lib/benchmarks/bench_arraysetops.py =================================================================== --- trunk/numpy/lib/benchmarks/bench_arraysetops.py 2008-07-23 13:23:52 UTC (rev 5510) +++ trunk/numpy/lib/benchmarks/bench_arraysetops.py 2008-07-23 13:51:45 UTC (rev 5511) @@ -0,0 +1,65 @@ +import numpy as np +import time +from numpy.lib.arraysetops import * + +def bench_unique1d( plot_results = False ): + exponents = np.linspace( 2, 7, 9 ) + ratios = [] + nItems = [] + dt1s = [] + dt2s = [] + for ii in exponents: + + nItem = 10 ** ii + print 'using %d items:' % nItem + a = np.fix( nItem / 10 * np.random.random( nItem ) ) + + print 'unique:' + tt = time.clock() + b = np.unique( a ) + dt1 = time.clock() - tt + print dt1 + + print 'unique1d:' + tt = time.clock() + c = unique1d( a ) + dt2 = time.clock() - tt + print dt2 + + + if dt1 < 1e-8: + ratio = 'ND' + else: + ratio = dt2 / dt1 + print 'ratio:', ratio + print 'nUnique: %d == %d\n' % (len( b ), len( c )) + + nItems.append( nItem ) + ratios.append( ratio ) + dt1s.append( dt1 ) + dt2s.append( dt2 ) + + assert np.alltrue( b == c ) + + print nItems + print dt1s + print dt2s + print ratios + + if plot_results: + import pylab + + def plotMe( fig, fun, nItems, dt1s, dt2s ): + pylab.figure( fig ) + fun( nItems, dt1s, 'g-o', linewidth = 2, markersize = 8 ) + fun( nItems, dt2s, 'b-x', linewidth = 2, markersize = 8 ) + pylab.legend( ('unique', 'unique1d' ) ) + pylab.xlabel( 'nItem' ) + pylab.ylabel( 'time [s]' ) + + plotMe( 1, pylab.loglog, nItems, dt1s, dt2s ) + plotMe( 2, pylab.plot, nItems, dt1s, dt2s ) + pylab.show() + +if __name__ == '__main__': + bench_unique1d( plot_results = True ) From numpy-svn at scipy.org Wed Jul 23 12:46:27 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 23 Jul 2008 11:46:27 -0500 (CDT) Subject: [Numpy-svn] r5512 - tags Message-ID: <20080723164627.73E4739C2C6@scipy.org> Author: jarrod.millman Date: 2008-07-23 11:46:23 -0500 (Wed, 23 Jul 2008) New Revision: 5512 Added: tags/1.1.1rc2/ Log: tagged 1.1.1rc2 Copied: tags/1.1.1rc2 (from rev 5511, branches/1.1.x) From numpy-svn at scipy.org Wed Jul 23 12:48:03 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 23 Jul 2008 11:48:03 -0500 (CDT) Subject: [Numpy-svn] r5513 - tags/1.1.1rc2/numpy Message-ID: <20080723164803.E978739C2C6@scipy.org> Author: jarrod.millman Date: 2008-07-23 11:48:01 -0500 (Wed, 23 Jul 2008) New Revision: 5513 Modified: tags/1.1.1rc2/numpy/version.py Log: updating version information Modified: tags/1.1.1rc2/numpy/version.py =================================================================== --- tags/1.1.1rc2/numpy/version.py 2008-07-23 16:46:23 UTC (rev 5512) +++ tags/1.1.1rc2/numpy/version.py 2008-07-23 16:48:01 UTC (rev 5513) @@ -1,5 +1,5 @@ -version='1.1.1' -release=False +version='1.1.1rc2' +release=True if not release: version += '.dev' From numpy-svn at scipy.org Thu Jul 24 00:12:40 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 23 Jul 2008 23:12:40 -0500 (CDT) Subject: [Numpy-svn] r5514 - trunk Message-ID: <20080724041240.E8AE7C7C004@scipy.org> Author: cdavid Date: 2008-07-23 23:12:37 -0500 (Wed, 23 Jul 2008) New Revision: 5514 Modified: trunk/README.txt Log: Add some more info for installing numpy. Modified: trunk/README.txt =================================================================== --- trunk/README.txt 2008-07-23 16:48:01 UTC (rev 5513) +++ trunk/README.txt 2008-07-24 04:12:37 UTC (rev 5514) @@ -1,8 +1,14 @@ NumPy is a replacement of Numeric Python that adds the features of numarray. -To install system-wide: +To install system-wide on Unix-like systems: sudo python setup.py install +or (for system without sudo): + +su -c python setup.py install + +On windows, it is advised to use the official binaries. + The setup.py script will take advantage of fast BLAS on your system if it can find it. You can guide the process using a site.cfg file. From numpy-svn at scipy.org Thu Jul 24 00:29:44 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 23 Jul 2008 23:29:44 -0500 (CDT) Subject: [Numpy-svn] r5515 - trunk Message-ID: <20080724042944.D8E3EC7C004@scipy.org> Author: cdavid Date: 2008-07-23 23:29:40 -0500 (Wed, 23 Jul 2008) New Revision: 5515 Added: trunk/INSTALL.txt Log: Start working on a INSTALL.txt document for building/installing numpy. Added: trunk/INSTALL.txt =================================================================== --- trunk/INSTALL.txt 2008-07-24 04:12:37 UTC (rev 5514) +++ trunk/INSTALL.txt 2008-07-24 04:29:40 UTC (rev 5515) @@ -0,0 +1,30 @@ +.. -*- rest -*- +.. vim:syntax=rest +.. NB! Keep this document a valid restructured document. + +Building and installing NumPy ++++++++++++++++++++++++++++++ + +:Authors: Numpy Developers +:Discussions to: numpy-discussion at scipy.org + +.. Contents:: + +PREREQUISITES +============= + +Building NumPy requires the following software installed: + +1) Python__ 2.4.x or newer + + On Debian and derivative (Ubuntu): python python-dev + + On Windows: the official python installer on Python__ is enough + + Make sure that the Python package distutils is installed before + continuing. For example, in Debian GNU/Linux, distutils is included + in the python-dev package. + + Python must also be compiled with the zlib module enabled. + +__ http://www.python.org From numpy-svn at scipy.org Thu Jul 24 01:28:39 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 24 Jul 2008 00:28:39 -0500 (CDT) Subject: [Numpy-svn] r5516 - trunk/numpy/lib/tests Message-ID: <20080724052839.02D6A39C192@scipy.org> Author: alan.mcintyre Date: 2008-07-24 00:28:37 -0500 (Thu, 24 Jul 2008) New Revision: 5516 Modified: trunk/numpy/lib/tests/test_financial.py Log: Added tests to improve coverage. Converted tests from doctests to unit tests. Modified: trunk/numpy/lib/tests/test_financial.py =================================================================== --- trunk/numpy/lib/tests/test_financial.py 2008-07-24 04:29:40 UTC (rev 5515) +++ trunk/numpy/lib/tests/test_financial.py 2008-07-24 05:28:37 UTC (rev 5516) @@ -1,38 +1,57 @@ -""" ->>> np.round(np.rate(10,0,-3500,10000),4)==0.1107 -True +from numpy.testing import * +import numpy as np ->>> np.round(np.irr([-150000, 15000, 25000, 35000, 45000, 60000]),4)==0.0524 -True +class TestFinancial(TestCase): + def test_rate(self): + assert_almost_equal(np.rate(10,0,-3500,10000), + 0.1107, 4) ->>> np.round(np.pv(0.07,20,12000,0),2) == -127128.17 -True + def test_irr(self): + v = [-150000, 15000, 25000, 35000, 45000, 60000] + assert_almost_equal(np.irr(v), + 0.0524, 2) ->>> np.round(np.fv(0.075, 20, -2000,0,0),2) == 86609.36 -True + def test_pv(self): + assert_almost_equal(np.pv(0.07,20,12000,0), + -127128.17, 2) ->>> np.round(np.pmt(0.08/12,5*12,15000),3) == -304.146 -True + def test_fv(self): + assert_almost_equal(np.fv(0.075, 20, -2000,0,0), + 86609.36, 2) ->>> np.round(np.nper(0.075,-2000,0,100000.),2) == 21.54 -True + def test_pmt(self): + assert_almost_equal(np.pmt(0.08/12,5*12,15000), + -304.146, 3) ->>> np.round(np.npv(0.05,[-15000,1500,2500,3500,4500,6000]),2) == 117.04 -True + def test_nper(self): + assert_almost_equal(np.nper(0.075,-2000,0,100000.), + 21.54, 2) ->>> np.round(np.mirr([-4500,-800,800,800,600,600,800,800,700,3000],0.08,0.055),4) == 0.0665 -True + def test_nper(self): + assert_almost_equal(np.nper(0.0,-2000,0,100000.), + 50.0, 1) ->>> np.round(np.mirr([-120000,39000,30000,21000,37000,46000],0.10,0.12),4)==0.1344 -True -""" + def test_npv(self): + assert_almost_equal(np.npv(0.05,[-15000,1500,2500,3500,4500,6000]), + 117.04, 2) -from numpy.testing import * -import numpy as np + def test_mirr(self): + v1 = [-4500,-800,800,800,600,600,800,800,700,3000] + assert_almost_equal(np.mirr(v1,0.08,0.055), + 0.0665, 4) -def test(): - import doctest - doctest.testmod() + v2 = [-120000,39000,30000,21000,37000,46000] + assert_almost_equal(np.mirr(v2,0.10,0.12), + 0.1344, 4) + +def test_unimplemented(): + # np.round(np.ppmt(0.1/12,1,60,55000),2) == 710.25 + assert_raises(NotImplementedError, np.ppmt, 0.1/12, 1, 60, 55000) + + # np.round(np.ipmt(0.1/12,1,24,2000),2) == 16.67 + assert_raises(NotImplementedError, np.ipmt, 0.1/12, 1, 24, 2000) + + if __name__ == "__main__": run_module_suite() From numpy-svn at scipy.org Fri Jul 25 09:28:38 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 25 Jul 2008 08:28:38 -0500 (CDT) Subject: [Numpy-svn] r5517 - / Message-ID: <20080725132838.B3D4739C8CD@scipy.org> Author: cdavid Date: 2008-07-25 08:28:34 -0500 (Fri, 25 Jul 2008) New Revision: 5517 Added: vendor/ Log: Create a vendor directory to keep blas, lapack and other dependencies for a complete numpy/scipy. From numpy-svn at scipy.org Fri Jul 25 10:32:32 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 25 Jul 2008 09:32:32 -0500 (CDT) Subject: [Numpy-svn] r5520 - vendor/src/lapack-lite-3.1.1 Message-ID: <20080725143232.F1DB839C100@scipy.org> Author: cdavid Date: 2008-07-25 09:32:29 -0500 (Fri, 25 Jul 2008) New Revision: 5520 Added: vendor/src/lapack-lite-3.1.1/make.inc Log: Add make.inc for compiling lapack on windows (mignw compilers). Added: vendor/src/lapack-lite-3.1.1/make.inc =================================================================== --- vendor/src/lapack-lite-3.1.1/make.inc 2008-07-25 14:06:06 UTC (rev 5519) +++ vendor/src/lapack-lite-3.1.1/make.inc 2008-07-25 14:32:29 UTC (rev 5520) @@ -0,0 +1,55 @@ +#################################################################### +# LAPACK make include file. # +# LAPACK, Version 3.1.1 # +# February 2007 # +#################################################################### +# +SHELL = /bin/sh +# +# The machine (platform) identifier to append to the library names +# +PLAT = _MINGW32 +# +# Modify the FORTRAN and OPTS definitions to refer to the +# compiler and desired compiler options for your machine. NOOPT +# refers to the compiler options desired when NO OPTIMIZATION is +# selected. Define LOADER and LOADOPTS to refer to the loader and +# desired load options for your machine. +# +FORTRAN = g77 +OPTS = +DRVOPTS = $(OPTS) +NOOPT = +LOADER = g77 +LOADOPTS = +# +# Timer for the SECOND and DSECND routines +# +# Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME +TIMER = EXT_ETIME +# For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_ +# TIMER = EXT_ETIME_ +# For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME +# TIMER = INT_ETIME +# If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...) +# SECOND and DSECND will use a call to the INTERNAL FUNCTION CPU_TIME +# TIMER = INT_CPU_TIME +# If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0 +# TIMER = NONE +# +# The archiver and the flag(s) to use when building archive (library) +# If you system has no ranlib, set RANLIB = echo. +# +ARCH = ar +ARCHFLAGS= cr +RANLIB = ranlib +# +# The location of the libraries to which you will link. (The +# machine-specific, optimized BLAS library should be used whenever +# possible.) +# +BLASLIB = ../../blas$(PLAT).a +LAPACKLIB = lapack$(PLAT).a +TMGLIB = tmglib$(PLAT).a +EIGSRCLIB = eigsrc$(PLAT).a +LINSRCLIB = linsrc$(PLAT).a From numpy-svn at scipy.org Fri Jul 25 10:32:56 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 25 Jul 2008 09:32:56 -0500 (CDT) Subject: [Numpy-svn] r5521 - vendor/src/lapack-lite-3.1.1/INSTALL Message-ID: <20080725143256.8C9B339C100@scipy.org> Author: cdavid Date: 2008-07-25 09:32:53 -0500 (Fri, 25 Jul 2008) New Revision: 5521 Modified: vendor/src/lapack-lite-3.1.1/INSTALL/Makefile Log: Fix clean of install subdir Makefile. Modified: vendor/src/lapack-lite-3.1.1/INSTALL/Makefile =================================================================== --- vendor/src/lapack-lite-3.1.1/INSTALL/Makefile 2008-07-25 14:32:29 UTC (rev 5520) +++ vendor/src/lapack-lite-3.1.1/INSTALL/Makefile 2008-07-25 14:32:53 UTC (rev 5521) @@ -28,6 +28,7 @@ clean: rm -f *.o + rm -f testlsame testslamch testdlamch testsecond testdsecnd testieee testversion slamch.o: slamch.f ; $(FORTRAN) $(NOOPT) -c $< -o $@ dlamch.o: dlamch.f ; $(FORTRAN) $(NOOPT) -c $< -o $@ From numpy-svn at scipy.org Fri Jul 25 10:47:03 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 25 Jul 2008 09:47:03 -0500 (CDT) Subject: [Numpy-svn] r5522 - in vendor: . tools Message-ID: <20080725144703.4AB9339C3AB@scipy.org> Author: cdavid Date: 2008-07-25 09:46:58 -0500 (Fri, 25 Jul 2008) New Revision: 5522 Added: vendor/tools/ vendor/tools/build.py Log: Add basic script to build atlas + lapack with g77. Added: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-25 14:32:53 UTC (rev 5521) +++ vendor/tools/build.py 2008-07-25 14:46:58 UTC (rev 5522) @@ -0,0 +1,69 @@ +#! /usr/bin/python + +from subprocess import Popen +import shutil +import os.path +from os.path import join as pjoin +import glob +import tarfile + +# Configuration (this should be put in a config file at some point) +LAPACK_SRC = pjoin('src', 'lapack-lite-3.1.1') +LAPACK_LIB = pjoin(LAPACK_SRC, 'lapack_MINGW32.a') +ATLAS_SRC = pjoin('src', 'atlas-3.8.2') +ATLAS_BUILDDIR = os.path.join(ATLAS_SRC, "MyObj") +ARCH = "SSE2-P4" +ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH +FC = 'g77' +# Use INT_ETIME for lapack if building with gfortran +#TIMER = 'INT_ETIME' +LAPACK_F77_FLAGS = '' + +def build_atlas_tarball(): + print "====== Building ATLAS tarbal ======" + files = glob.glob(ATLAS_BUILDDIR + '/lib/*.a') + fid = tarfile.open(ATLAS_TARBALL, 'w:bz2') + try: + for f in files: + fid.add(f) + finally: + fid.close() + +def build_atlas(): + print "====== Building ATLAS ======" + p = Popen(['make'], cwd = ATLAS_BUILDDIR) + os.waitpid(p.pid, 0) + +def configure_atlas(): + print "====== Configuring ATLAS ======" + if os.path.exists(ATLAS_BUILDDIR): + shutil.rmtree(ATLAS_BUILDDIR) + os.makedirs(ATLAS_BUILDDIR) + p = Popen(['../configure', '--with-netlib-lapack=%s' % LAPACK_LIB, '-C', 'if', FC], cwd = ATLAS_BUILDDIR) + os.waitpid(p.pid, 0) + +def build_lapack(): + print "====== Build LAPACK ======" + p = Popen(["make", "lapacklib", "FORTRAN=%s" % FC, "LOADER=%s" % FC, "OPTS=%s" % LAPACK_F77_FLAGS], cwd = LAPACK_SRC) + os.waitpid(p.pid, 0) + +def clean_lapack(): + print "====== Clean LAPACK ======" + p = Popen(['make', 'cleanlib'], cwd = LAPACK_SRC) + os.waitpid(p.pid, 0) + +def clean_atlas(): + print "====== Clean ATLAS ======" + if os.path.exists(ATLAS_BUILDDIR): + shutil.rmtree(ATLAS_BUILDDIR) + +def clean(): + clean_atlas() + clean_lapack() + +if __name__ == '__main__': + clean() + build_lapack() + configure_atlas() + build_atlas() + build_atlas_tarball() From numpy-svn at scipy.org Fri Jul 25 11:08:17 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 25 Jul 2008 10:08:17 -0500 (CDT) Subject: [Numpy-svn] r5523 - vendor/tools Message-ID: <20080725150817.C9E3C39C100@scipy.org> Author: cdavid Date: 2008-07-25 10:08:12 -0500 (Fri, 25 Jul 2008) New Revision: 5523 Added: vendor/tools/superpack.nsi Log: Add nsi script to build the blas-lapack superpack with auto-detected ARCH. Added: vendor/tools/superpack.nsi =================================================================== --- vendor/tools/superpack.nsi 2008-07-25 14:46:58 UTC (rev 5522) +++ vendor/tools/superpack.nsi 2008-07-25 15:08:12 UTC (rev 5523) @@ -0,0 +1,313 @@ +;NSIS Modern User Interface +;Basic Example Script +;Written by Joost Verburg, adapted by David Cournapeau for blas/lapack +;installer + +!define PRODUCT_NAME "BlasLapack superpack" + +;-------------------------------- +;Extra headers necessary + +!include 'MUI.nsh' +!include 'Sections.nsh' +!include 'LogicLib.nsh' + +;SetCompress off ; Useful to disable compression under development + +;-------------------------------- +;General + +;Name and file +Name "${PRODUCT_NAME}" +OutFile "setup.exe" + +;Default installation folder +InstallDir "$PROGRAMFILES\${PRODUCT_NAME}" + +;Get installation folder from registry if available +InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" "" + +;-------------------------------- +;Interface Settings + +!define MUI_ABORTWARNING + +;-------------------------------- +;Pages + +;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +; !insertmacro MUI_PAGE_FINISH_TEXT "Installation done ! DO NOT FORGET TO PUT THE INSTALLED DLL SOMEWHERE WHERE THEY CAN BE FOUND BY WINDOWS !" + +;-------------------------------- +;Languages + +!insertmacro MUI_LANGUAGE "English" + +;-------------------------- +; Types of installation +; - default: install most optimized available, mingw only (toward people who just want thing to work) +; - custom: choose whatever you want +; - install everything +InstType "Typical" +InstType "Full" + +;-------------------------------- +;Component Sections + +Var HasSSE2 +Var HasSSE3 +Var CPUSSE + +SubSection "Generic BLAS" BLAS + Section "Mingw archives" BLAS_MINGW + SetOutPath "$INSTDIR\Generic\mingw32" + File "installed\generic\mingw32\libblas.a" + SectionEnd + + Section "Dynamic libraries" BLAS_DLL + SetOutPath "$INSTDIR\Generic\dll" + File "installed\generic\vs-core\blas.dll" + SectionEnd + + Section "Import libraries" BLAS_VSLIB + SetOutPath "$INSTDIR\Generic\lib" + File "installed\generic\vs-dev\blas.def" + File "installed\generic\vs-dev\blas.lib" + SectionEnd +SubSectionEnd + +SubSection "Generic LAPACK" LAPACK + Section "Mingw archives" LAPACK_MINGW + SetOutPath "$INSTDIR\Generic\mingw32" + File "installed\generic\mingw32\liblapack.a" + SectionEnd + + Section "Dynamic libraries" LAPACK_DLL + SetOutPath "$INSTDIR\Generic\dll" + File "installed\generic\vs-core\lapack.dll" + SectionEnd + + Section "Import libraries" LAPACK_VSLIB + SetOutPath "$INSTDIR\Generic\lib" + File "installed\generic\vs-dev\lapack.def" + File "installed\generic\vs-dev\lapack.lib" + SectionEnd +SubSectionEnd + +SubSection "ATLAS" ATLAS + SubSection "SSE2" ATLAS_SSE2 + Section "Mingw archives" ATLAS_SSE2_MINGW + SetOutPath "$INSTDIR\ATLAS\sse2\mingw32" + File "installed\ATLAS\sse2\mingw32\lib*.a" + SectionEnd + + Section "Dynamic libraries" ATLAS_SSE2_DLL + SetOutPath "$INSTDIR\ATLAS\sse2\dll" + File "installed\ATLAS\sse2\vs-core\*.dll" + SectionEnd + + Section "Import libraries" ATLAS_SSE2_VSLIB + SetOutPath "$INSTDIR\ATLAS\sse2\lib" + File "installed\ATLAS\sse2\vs-dev\*.lib" + File "installed\ATLAS\sse2\vs-dev\*.def" + SectionEnd + SubSectionEnd + + SubSection "SSE3" ATLAS_SSE3 + Section "Mingw archives" ATLAS_SSE3_MINGW + SetOutPath "$INSTDIR\ATLAS\sse3\mingw32" + File "installed\ATLAS\sse3\mingw32\lib*.a" + SectionEnd + + Section "Dynamic libraries" ATLAS_SSE3_DLL + SetOutPath "$INSTDIR\ATLAS\sse3\dll" + File "installed\ATLAS\sse3\vs-core\*.dll" + SectionEnd + + Section "Import libraries" ATLAS_SSE3_VSLIB + SetOutPath "$INSTDIR\ATLAS\sse3\lib" + File "installed\ATLAS\sse3\vs-dev\*.lib" + File "installed\ATLAS\sse3\vs-dev\*.def" + SectionEnd + SubSectionEnd +SubSectionEnd + +Section -Post + ;Create uninstaller + WriteUninstaller "$INSTDIR\Uninstall.exe" +SectionEnd + +Section -Dummy DUMMY +SectionEnd + +Function .onInit + ; Detect CPU target capabilities for ATLAS + StrCpy $CPUSSE "0" + CpuCaps::hasSSE3 + Pop $0 + StrCpy $HasSSE3 $0 + CpuCaps::hasSSE2 + Pop $0 + StrCpy $HasSSE2 $0 + + ; Take care about the order ! + + ; SSE 2 + StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 + include_sse2: + StrCpy $CPUSSE "2" + goto done_sse2 + no_include_sse2: + goto done_sse2 + done_sse2: + + ; SSE 3 + StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 + include_sse3: + StrCpy $CPUSSE "3" + goto done_sse3 + no_include_sse3: + goto done_sse3 + done_sse3: + + ${Switch} $CPUSSE + ${Case} "3" + !insertmacro SetSectionInInstType "${ATLAS_SSE3_MINGW}" "1" + ${Break} + ${Case} "2" + !insertmacro SetSectionInInstType "${ATLAS_SSE2_MINGW}" "1" + ${Break} + ${Default} + !insertmacro SetSectionInInstType "${BLAS_MINGW}" "1" + !insertmacro SetSectionInInstType "${LAPACK_MINGW}" "1" + ${Break} + ${EndSwitch} + + !insertmacro SetSectionInInstType "${BLAS_MINGW}" "2" + !insertmacro SetSectionInInstType "${BLAS_DLL}" "2" + !insertmacro SetSectionInInstType "${BLAS_VSLIB}" "2" + + !insertmacro SetSectionInInstType "${LAPACK_MINGW}" "2" + !insertmacro SetSectionInInstType "${LAPACK_DLL}" "2" + !insertmacro SetSectionInInstType "${LAPACK_VSLIB}" "2" + + !insertmacro SetSectionInInstType "${ATLAS_SSE2_MINGW}" "2" + !insertmacro SetSectionInInstType "${ATLAS_SSE2_DLL}" "2" + !insertmacro SetSectionInInstType "${ATLAS_SSE2_VSLIB}" "2" + + !insertmacro SetSectionInInstType "${ATLAS_SSE3_MINGW}" "2" + !insertmacro SetSectionInInstType "${ATLAS_SSE3_DLL}" "2" + !insertmacro SetSectionInInstType "${ATLAS_SSE3_VSLIB}" "2" + + SetCurInstType "0" + WriteRegStr HKCU "Software\${PRODUCT_NAME}" "" $INSTDIR +FunctionEnd + +;-------------------------------- +;Descriptions +;Language strings +LangString DESC_BLAS ${LANG_ENGLISH} "This section contains BLAS libraries.\ + Those are generic, non optimized libraries (from netlib)." +LangString DESC_LAPACK ${LANG_ENGLISH} "This section contains LAPACK libraries.\ + Those are generic, non optimized libraries (from netlib)." + +LangString DESC_ATLAS ${LANG_ENGLISH} "This section contains ATLAS libraries.\ + Those are optimized libraries for BLAS and LAPACK." +LangString DESC_ATLAS_SSE2 ${LANG_ENGLISH} "This section contains ATLAS libraries \ + for CPU supporting at least SSE2. " +LangString DESC_ATLAS_SSE3 ${LANG_ENGLISH} "This section contains ATLAS libraries \ + for CPU supporting at least SSE3. " + +LangString DESC_MINGW ${LANG_ENGLISH} "This will install .a libraries: \ + this is what you need if you compile numpy with mingw32 compilers." +LangString DESC_DLL ${LANG_ENGLISH} "This will install .dll libraries: \ + this is can be used instead of the static archives." +LangString DESC_VSLIB ${LANG_ENGLISH} "This will install .lib import \ + libraries and .def files: this is needed for advanced use of the dll, \ + or to link against the dll with Visual Studio." + +;Assign language strings to sections +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${BLAS} $(DESC_BLAS) + !insertmacro MUI_DESCRIPTION_TEXT ${BLAS_MINGW} $(DESC_MINGW) + !insertmacro MUI_DESCRIPTION_TEXT ${BLAS_DLL} $(DESC_DLL) + !insertmacro MUI_DESCRIPTION_TEXT ${BLAS_VSLIB} $(DESC_VSLIB) + + !insertmacro MUI_DESCRIPTION_TEXT ${LAPACK} $(DESC_LAPACK) + !insertmacro MUI_DESCRIPTION_TEXT ${LAPACK_MINGW} $(DESC_MINGW) + !insertmacro MUI_DESCRIPTION_TEXT ${LAPACK_DLL} $(DESC_DLL) + !insertmacro MUI_DESCRIPTION_TEXT ${LAPACK_VSLIB} $(DESC_VSLIB) + + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS} $(DESC_ATLAS) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE2} $(DESC_ATLAS_SSE2) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE2_MINGW} $(DESC_MINGW) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE2_DLL} $(DESC_DLL) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE2_VSLIB} $(DESC_VSLIB) + + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE3} $(DESC_ATLAS_SSE3) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE3_MINGW} $(DESC_MINGW) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE3_DLL} $(DESC_DLL) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE3_VSLIB} $(DESC_VSLIB) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + +;-------------------------------- +;Uninstaller Section + +Section "Uninstall" + + Delete "$INSTDIR\Uninstall.exe" + + ; XXX: we should track the installed files instead, but I am lazy + + ; Generic libs + Delete "$INSTDIR\generic\mingw32\libblas.a" + Delete "$INSTDIR\generic\mingw32\liblapack.a" + RMDir "$INSTDIR\generic\mingw32" + + Delete "$INSTDIR\generic\dll\blas.dll" + Delete "$INSTDIR\generic\dll\lapack.dll" + RMDir "$INSTDIR\generic\dll" + + Delete "$INSTDIR\generic\lib\blas.def" + Delete "$INSTDIR\generic\lib\blas.lib" + Delete "$INSTDIR\generic\lib\lapack.def" + Delete "$INSTDIR\generic\lib\lapack.lib" + RMDir "$INSTDIR\generic\lib" + RMDir "$INSTDIR\generic" + + ; ATLAS SSE2 + Delete "$INSTDIR\ATLAS\sse2\mingw32\*.a" + RMDir "$INSTDIR\ATLAS\sse2\mingw32" + + Delete "$INSTDIR\ATLAS\sse2\dll\*.dll" + RMDir "$INSTDIR\ATLAS\sse2\dll" + + Delete "$INSTDIR\ATLAS\sse2\lib\*.lib" + Delete "$INSTDIR\ATLAS\sse2\lib\*.def" + RMDir "$INSTDIR\ATLAS\sse2\lib" + RMDir "$INSTDIR\ATLAS\sse2" + + ; ATLAS SSE2 + Delete "$INSTDIR\ATLAS\sse3\mingw32\*.a" + RMDir "$INSTDIR\ATLAS\sse3\mingw32" + + Delete "$INSTDIR\ATLAS\sse3\dll\*.dll" + RMDir "$INSTDIR\ATLAS\sse3\dll" + + Delete "$INSTDIR\ATLAS\sse3\lib\*.lib" + Delete "$INSTDIR\ATLAS\sse3\lib\*.def" + RMDir "$INSTDIR\ATLAS\sse3\lib" + RMDir "$INSTDIR\ATLAS\sse3" + RMDir "$INSTDIR\ATLAS" + + RMDir "$INSTDIR" + + DeleteRegKey /ifempty HKCU "Software\${PRODUCT_NAME}" + +SectionEnd From numpy-svn at scipy.org Fri Jul 25 12:09:30 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 25 Jul 2008 11:09:30 -0500 (CDT) Subject: [Numpy-svn] r5524 - in trunk/numpy: oldnumeric random/mtrand Message-ID: <20080725160930.98D6A39C663@scipy.org> Author: alan.mcintyre Date: 2008-07-25 11:09:26 -0500 (Fri, 25 Jul 2008) New Revision: 5524 Modified: trunk/numpy/oldnumeric/random_array.py trunk/numpy/random/mtrand/mtrand.pyx Log: Standardize NumPy import as "import numpy as np". Modified: trunk/numpy/oldnumeric/random_array.py =================================================================== --- trunk/numpy/oldnumeric/random_array.py 2008-07-25 15:08:12 UTC (rev 5523) +++ trunk/numpy/oldnumeric/random_array.py 2008-07-25 16:09:26 UTC (rev 5524) @@ -10,7 +10,7 @@ ArgumentError = ValueError import numpy.random.mtrand as mt -import numpy as Numeric +import numpy as np def seed(x=0, y=0): if (x == 0 or y == 0): @@ -48,8 +48,8 @@ if not isinstance(maximum, int): raise ArgumentError, "randint requires second argument integer" a = ((maximum-minimum)* random(shape)) - if isinstance(a, Numeric.ndarray): - return minimum + a.astype(Numeric.int) + if isinstance(a, np.ndarray): + return minimum + a.astype(np.int) else: return minimum + int(a) @@ -164,7 +164,7 @@ trials is the number of trials in each multinomial distribution. probs is a one dimensional array. There are len(prob)+1 events. prob[i] is the probability of the i-th event, 0<=i= 0.6: + if np.minimum.reduce(y) <= 0.5 or np.maximum.reduce(y) >= 0.6: raise SystemExit, "uniform returned out of desired range" print "randint(1, 10, shape=[50])" print randint(1, 10, shape=[50]) @@ -229,26 +229,26 @@ mean_var_test(x, "normally distributed numbers with mean 2 and variance %f"%(s**2,), 2, s**2, 0) x = exponential(3, 10000) mean_var_test(x, "random numbers exponentially distributed with mean %f"%(s,), s, s**2, 2) - x = multivariate_normal(Numeric.array([10,20]), Numeric.array(([1,2],[2,4]))) + x = multivariate_normal(np.array([10,20]), np.array(([1,2],[2,4]))) print "\nA multivariate normal", x if x.shape != (2,): raise SystemExit, "multivariate_normal returned wrong shape" - x = multivariate_normal(Numeric.array([10,20]), Numeric.array([[1,2],[2,4]]), [4,3]) + x = multivariate_normal(np.array([10,20]), np.array([[1,2],[2,4]]), [4,3]) print "A 4x3x2 array containing multivariate normals" print x if x.shape != (4,3,2): raise SystemExit, "multivariate_normal returned wrong shape" - x = multivariate_normal(Numeric.array([-100,0,100]), Numeric.array([[3,2,1],[2,2,1],[1,1,1]]), 10000) - x_mean = Numeric.sum(x,axis=0)/10000. + x = multivariate_normal(np.array([-100,0,100]), np.array([[3,2,1],[2,2,1],[1,1,1]]), 10000) + x_mean = np.sum(x,axis=0)/10000. print "Average of 10000 multivariate normals with mean [-100,0,100]" print x_mean x_minus_mean = x - x_mean print "Estimated covariance of 10000 multivariate normals with covariance [[3,2,1],[2,2,1],[1,1,1]]" - print Numeric.dot(Numeric.transpose(x_minus_mean),x_minus_mean)/9999. + print np.dot(np.transpose(x_minus_mean),x_minus_mean)/9999. x = beta(5.0, 10.0, 10000) mean_var_test(x, "beta(5.,10.) random numbers", 0.333, 0.014) x = gamma(.01, 2., 10000) mean_var_test(x, "gamma(.01,2.) random numbers", 2*100, 2*100*100) x = chi_square(11., 10000) - mean_var_test(x, "chi squared random numbers with 11 degrees of freedom", 11, 22, 2*Numeric.sqrt(2./11.)) + mean_var_test(x, "chi squared random numbers with 11 degrees of freedom", 11, 22, 2*np.sqrt(2./11.)) x = F(5., 10., 10000) mean_var_test(x, "F random numbers with 5 and 10 degrees of freedom", 1.25, 1.35) x = poisson(50., 10000) @@ -260,7 +260,7 @@ print "\nEach row is the result of 16 multinomial trials with probabilities [0.1, 0.5, 0.1 0.3]:" x = multinomial(16, [0.1, 0.5, 0.1], 8) print x - print "Mean = ", Numeric.sum(x,axis=0)/8. + print "Mean = ", np.sum(x,axis=0)/8. if __name__ == '__main__': test() Modified: trunk/numpy/random/mtrand/mtrand.pyx =================================================================== --- trunk/numpy/random/mtrand/mtrand.pyx 2008-07-25 15:08:12 UTC (rev 5523) +++ trunk/numpy/random/mtrand/mtrand.pyx 2008-07-25 16:09:26 UTC (rev 5524) @@ -119,7 +119,7 @@ # Initialize numpy import_array() -import numpy as _sp +import numpy as np cdef object cont0_array(rk_state *state, rk_cont0 func, object size): cdef double *array_data @@ -130,7 +130,7 @@ if size is None: return func(state) else: - array = _sp.empty(size, _sp.float64) + array = np.empty(size, np.float64) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -147,7 +147,7 @@ if size is None: return func(state, a) else: - array = _sp.empty(size, _sp.float64) + array = np.empty(size, np.float64) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -172,7 +172,7 @@ array_data[i] = func(state, ((itera.dataptr))[0]) PyArray_ITER_NEXT(itera) else: - array = _sp.empty(size, _sp.float64) + array = np.empty(size, np.float64) array_data = array.data multi = PyArray_MultiIterNew(2, array, oa) @@ -194,7 +194,7 @@ if size is None: return func(state, a, b) else: - array = _sp.empty(size, _sp.float64) + array = np.empty(size, np.float64) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -222,7 +222,7 @@ array_data[i] = func(state, oa_data[0], ob_data[0]) PyArray_MultiIter_NEXT(multi) else: - array = _sp.empty(size, _sp.float64) + array = np.empty(size, np.float64) array_data = array.data multi = PyArray_MultiIterNew(3, array, oa, ob) if (multi.size != PyArray_SIZE(array)): @@ -246,7 +246,7 @@ if size is None: return func(state, a, b, c) else: - array = _sp.empty(size, _sp.float64) + array = np.empty(size, np.float64) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -276,7 +276,7 @@ array_data[i] = func(state, oa_data[0], ob_data[0], oc_data[0]) PyArray_MultiIter_NEXT(multi) else: - array = _sp.empty(size, _sp.float64) + array = np.empty(size, np.float64) array_data = array.data multi = PyArray_MultiIterNew(4, array, oa, ob, oc) @@ -299,7 +299,7 @@ if size is None: return func(state) else: - array = _sp.empty(size, int) + array = np.empty(size, int) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -315,7 +315,7 @@ if size is None: return func(state, n, p) else: - array = _sp.empty(size, int) + array = np.empty(size, int) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -341,7 +341,7 @@ array_data[i] = func(state, on_data[0], op_data[0]) PyArray_MultiIter_NEXT(multi) else: - array = _sp.empty(size, int) + array = np.empty(size, int) array_data = array.data multi = PyArray_MultiIterNew(3, array, on, op) if (multi.size != PyArray_SIZE(array)): @@ -365,7 +365,7 @@ if size is None: return func(state, n, m, N) else: - array = _sp.empty(size, int) + array = np.empty(size, int) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -394,7 +394,7 @@ array_data[i] = func(state, on_data[0], om_data[0], oN_data[0]) PyArray_MultiIter_NEXT(multi) else: - array = _sp.empty(size, int) + array = np.empty(size, int) array_data = array.data multi = PyArray_MultiIterNew(4, array, on, om, oN) @@ -418,7 +418,7 @@ if size is None: return func(state, a) else: - array = _sp.empty(size, int) + array = np.empty(size, int) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -443,7 +443,7 @@ array_data[i] = func(state, ((itera.dataptr))[0]) PyArray_ITER_NEXT(itera) else: - array = _sp.empty(size, int) + array = np.empty(size, int) array_data = array.data multi = PyArray_MultiIterNew(2, array, oa) if (multi.size != PyArray_SIZE(array)): @@ -512,7 +512,7 @@ errcode = rk_randomseed(self.internal_state) elif type(seed) is int: rk_seed(seed, self.internal_state) - elif isinstance(seed, _sp.integer): + elif isinstance(seed, np.integer): iseed = int(seed) rk_seed(iseed, self.internal_state) else: @@ -526,9 +526,9 @@ get_state() -> ('MT19937', int key[624], int pos, int has_gauss, float cached_gaussian) """ cdef ndarray state "arrayObject_state" - state = _sp.empty(624, _sp.uint) + state = np.empty(624, np.uint) memcpy((state.data), (self.internal_state.key), 624*sizeof(long)) - state = _sp.asarray(state, _sp.uint32) + state = np.asarray(state, np.uint32) return ('MT19937', state, self.internal_state.pos, self.internal_state.has_gauss, self.internal_state.gauss) @@ -575,7 +575,7 @@ self.set_state(state) def __reduce__(self): - return (_sp.random.__RandomState_ctor, (), self.get_state()) + return (np.random.__RandomState_ctor, (), self.get_state()) # Basic distributions: def random_sample(self, size=None): @@ -619,7 +619,7 @@ if size is None: return rk_interval(diff, self.internal_state) + lo else: - array = _sp.empty(size, int) + array = np.empty(size, int) length = PyArray_SIZE(array) array_data = array.data for i from 0 <= i < length: @@ -653,7 +653,7 @@ PyErr_Clear() olow = PyArray_FROM_OTF(low, NPY_DOUBLE, NPY_ALIGNED) ohigh = PyArray_FROM_OTF(high, NPY_DOUBLE, NPY_ALIGNED) - temp = _sp.subtract(ohigh, olow) + temp = np.subtract(ohigh, olow) Py_INCREF(temp) # needed to get around Pyrex's automatic reference-counting # rules because EnsureArray steals a reference odiff = PyArray_EnsureArray(temp) @@ -729,7 +729,7 @@ oloc = PyArray_FROM_OTF(loc, NPY_DOUBLE, NPY_ALIGNED) oscale = PyArray_FROM_OTF(scale, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oscale, 0)): + if np.any(np.less_equal(oscale, 0)): raise ValueError("scale <= 0") return cont2_array(self.internal_state, rk_normal, size, oloc, oscale) @@ -754,9 +754,9 @@ oa = PyArray_FROM_OTF(a, NPY_DOUBLE, NPY_ALIGNED) ob = PyArray_FROM_OTF(b, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oa, 0)): + if np.any(np.less_equal(oa, 0)): raise ValueError("a <= 0") - if _sp.any(_sp.less_equal(ob, 0)): + if np.any(np.less_equal(ob, 0)): raise ValueError("b <= 0") return cont2_array(self.internal_state, rk_beta, size, oa, ob) @@ -777,7 +777,7 @@ PyErr_Clear() oscale = PyArray_FROM_OTF(scale, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oscale, 0.0)): + if np.any(np.less_equal(oscale, 0.0)): raise ValueError("scale <= 0") return cont1_array(self.internal_state, rk_exponential, size, oscale) @@ -804,7 +804,7 @@ PyErr_Clear() oshape = PyArray_FROM_OTF(shape, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oshape, 0.0)): + if np.any(np.less_equal(oshape, 0.0)): raise ValueError("shape <= 0") return cont1_array(self.internal_state, rk_standard_gamma, size, oshape) @@ -828,9 +828,9 @@ PyErr_Clear() oshape = PyArray_FROM_OTF(shape, NPY_DOUBLE, NPY_ALIGNED) oscale = PyArray_FROM_OTF(scale, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oshape, 0.0)): + if np.any(np.less_equal(oshape, 0.0)): raise ValueError("shape <= 0") - if _sp.any(_sp.less_equal(oscale, 0.0)): + if np.any(np.less_equal(oscale, 0.0)): raise ValueError("scale <= 0") return cont2_array(self.internal_state, rk_gamma, size, oshape, oscale) @@ -855,9 +855,9 @@ odfnum = PyArray_FROM_OTF(dfnum, NPY_DOUBLE, NPY_ALIGNED) odfden = PyArray_FROM_OTF(dfden, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(odfnum, 0.0)): + if np.any(np.less_equal(odfnum, 0.0)): raise ValueError("dfnum <= 0") - if _sp.any(_sp.less_equal(odfden, 0.0)): + if np.any(np.less_equal(odfden, 0.0)): raise ValueError("dfden <= 0") return cont2_array(self.internal_state, rk_f, size, odfnum, odfden) @@ -888,11 +888,11 @@ odfden = PyArray_FROM_OTF(dfden, NPY_DOUBLE, NPY_ALIGNED) ononc = PyArray_FROM_OTF(nonc, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(odfnum, 1.0)): + if np.any(np.less_equal(odfnum, 1.0)): raise ValueError("dfnum <= 1") - if _sp.any(_sp.less_equal(odfden, 0.0)): + if np.any(np.less_equal(odfden, 0.0)): raise ValueError("dfden <= 0") - if _sp.any(_sp.less(ononc, 0.0)): + if np.any(np.less(ononc, 0.0)): raise ValueError("nonc < 0") return cont3_array(self.internal_state, rk_noncentral_f, size, odfnum, odfden, ononc) @@ -914,7 +914,7 @@ PyErr_Clear() odf = PyArray_FROM_OTF(df, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(odf, 0.0)): + if np.any(np.less_equal(odf, 0.0)): raise ValueError("df <= 0") return cont1_array(self.internal_state, rk_chisquare, size, odf) @@ -939,9 +939,9 @@ odf = PyArray_FROM_OTF(df, NPY_DOUBLE, NPY_ALIGNED) ononc = PyArray_FROM_OTF(nonc, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(odf, 0.0)): + if np.any(np.less_equal(odf, 0.0)): raise ValueError("df <= 1") - if _sp.any(_sp.less_equal(ononc, 0.0)): + if np.any(np.less_equal(ononc, 0.0)): raise ValueError("nonc < 0") return cont2_array(self.internal_state, rk_noncentral_chisquare, size, odf, ononc) @@ -970,7 +970,7 @@ PyErr_Clear() odf = PyArray_FROM_OTF(df, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(odf, 0.0)): + if np.any(np.less_equal(odf, 0.0)): raise ValueError("df <= 0") return cont1_array(self.internal_state, rk_standard_t, size, odf) @@ -994,7 +994,7 @@ omu = PyArray_FROM_OTF(mu, NPY_DOUBLE, NPY_ALIGNED) okappa = PyArray_FROM_OTF(kappa, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less(okappa, 0.0)): + if np.any(np.less(okappa, 0.0)): raise ValueError("kappa < 0") return cont2_array(self.internal_state, rk_vonmises, size, omu, okappa) @@ -1015,7 +1015,7 @@ PyErr_Clear() oa = PyArray_FROM_OTF(a, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oa, 0.0)): + if np.any(np.less_equal(oa, 0.0)): raise ValueError("a <= 0") return cont1_array(self.internal_state, rk_pareto, size, oa) @@ -1036,7 +1036,7 @@ PyErr_Clear() oa = PyArray_FROM_OTF(a, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oa, 0.0)): + if np.any(np.less_equal(oa, 0.0)): raise ValueError("a <= 0") return cont1_array(self.internal_state, rk_weibull, size, oa) @@ -1057,7 +1057,7 @@ PyErr_Clear() oa = PyArray_FROM_OTF(a, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oa, 0.0)): + if np.any(np.less_equal(oa, 0.0)): raise ValueError("a <= 0") return cont1_array(self.internal_state, rk_power, size, oa) @@ -1079,7 +1079,7 @@ PyErr_Clear() oloc = PyArray_FROM_OTF(loc, NPY_DOUBLE, NPY_ALIGNED) oscale = PyArray_FROM_OTF(scale, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oscale, 0.0)): + if np.any(np.less_equal(oscale, 0.0)): raise ValueError("scale <= 0") return cont2_array(self.internal_state, rk_laplace, size, oloc, oscale) @@ -1101,7 +1101,7 @@ PyErr_Clear() oloc = PyArray_FROM_OTF(loc, NPY_DOUBLE, NPY_ALIGNED) oscale = PyArray_FROM_OTF(scale, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oscale, 0.0)): + if np.any(np.less_equal(oscale, 0.0)): raise ValueError("scale <= 0") return cont2_array(self.internal_state, rk_gumbel, size, oloc, oscale) @@ -1123,7 +1123,7 @@ PyErr_Clear() oloc = PyArray_FROM_OTF(loc, NPY_DOUBLE, NPY_ALIGNED) oscale = PyArray_FROM_OTF(scale, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oscale, 0.0)): + if np.any(np.less_equal(oscale, 0.0)): raise ValueError("scale <= 0") return cont2_array(self.internal_state, rk_logistic, size, oloc, oscale) @@ -1152,7 +1152,7 @@ omean = PyArray_FROM_OTF(mean, NPY_DOUBLE, NPY_ALIGNED) osigma = PyArray_FROM_OTF(sigma, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(osigma, 0.0)): + if np.any(np.less_equal(osigma, 0.0)): raise ValueError("sigma <= 0.0") return cont2_array(self.internal_state, rk_lognormal, size, omean, osigma) @@ -1174,7 +1174,7 @@ PyErr_Clear() oscale = PyArray_FROM_OTF(scale, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oscale, 0.0)): + if np.any(np.less_equal(oscale, 0.0)): raise ValueError("scale <= 0.0") return cont1_array(self.internal_state, rk_rayleigh, size, oscale) @@ -1198,9 +1198,9 @@ PyErr_Clear() omean = PyArray_FROM_OTF(mean, NPY_DOUBLE, NPY_ALIGNED) oscale = PyArray_FROM_OTF(scale, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(omean,0.0)): + if np.any(np.less_equal(omean,0.0)): raise ValueError("mean <= 0.0") - elif _sp.any(_sp.less_equal(oscale,0.0)): + elif np.any(np.less_equal(oscale,0.0)): raise ValueError("scale <= 0.0") return cont2_array(self.internal_state, rk_wald, size, omean, oscale) @@ -1233,11 +1233,11 @@ omode = PyArray_FROM_OTF(mode, NPY_DOUBLE, NPY_ALIGNED) oright = PyArray_FROM_OTF(right, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.greater(oleft, omode)): + if np.any(np.greater(oleft, omode)): raise ValueError("left > mode") - if _sp.any(_sp.greater(omode, oright)): + if np.any(np.greater(omode, oright)): raise ValueError("mode > right") - if _sp.any(_sp.equal(oleft, oright)): + if np.any(np.equal(oleft, oright)): raise ValueError("left == right") return cont3_array(self.internal_state, rk_triangular, size, oleft, omode, oright) @@ -1267,11 +1267,11 @@ on = PyArray_FROM_OTF(n, NPY_LONG, NPY_ALIGNED) op = PyArray_FROM_OTF(p, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(n, 0)): + if np.any(np.less_equal(n, 0)): raise ValueError("n <= 0") - if _sp.any(_sp.less(p, 0)): + if np.any(np.less(p, 0)): raise ValueError("p < 0") - if _sp.any(_sp.greater(p, 1)): + if np.any(np.greater(p, 1)): raise ValueError("p > 1") return discnp_array(self.internal_state, rk_binomial, size, on, op) @@ -1301,11 +1301,11 @@ on = PyArray_FROM_OTF(n, NPY_LONG, NPY_ALIGNED) op = PyArray_FROM_OTF(p, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(n, 0)): + if np.any(np.less_equal(n, 0)): raise ValueError("n <= 0") - if _sp.any(_sp.less(p, 0)): + if np.any(np.less(p, 0)): raise ValueError("p < 0") - if _sp.any(_sp.greater(p, 1)): + if np.any(np.greater(p, 1)): raise ValueError("p > 1") return discnp_array(self.internal_state, rk_negative_binomial, size, on, op) @@ -1326,7 +1326,7 @@ PyErr_Clear() olam = PyArray_FROM_OTF(lam, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less(olam, 0)): + if np.any(np.less(olam, 0)): raise ValueError("lam < 0") return discd_array(self.internal_state, rk_poisson, size, olam) @@ -1347,7 +1347,7 @@ PyErr_Clear() oa = PyArray_FROM_OTF(a, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less_equal(oa, 1.0)): + if np.any(np.less_equal(oa, 1.0)): raise ValueError("a <= 1.0") return discd_array(self.internal_state, rk_zipf, size, oa) @@ -1372,9 +1372,9 @@ op = PyArray_FROM_OTF(p, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less(op, 0.0)): + if np.any(np.less(op, 0.0)): raise ValueError("p < 0.0") - if _sp.any(_sp.greater(op, 1.0)): + if np.any(np.greater(op, 1.0)): raise ValueError("p > 1.0") return discd_array(self.internal_state, rk_geometric, size, op) @@ -1412,13 +1412,13 @@ ongood = PyArray_FROM_OTF(ngood, NPY_LONG, NPY_ALIGNED) onbad = PyArray_FROM_OTF(nbad, NPY_LONG, NPY_ALIGNED) onsample = PyArray_FROM_OTF(nsample, NPY_LONG, NPY_ALIGNED) - if _sp.any(_sp.less(ongood, 1)): + if np.any(np.less(ongood, 1)): raise ValueError("ngood < 1") - if _sp.any(_sp.less(onbad, 1)): + if np.any(np.less(onbad, 1)): raise ValueError("nbad < 1") - if _sp.any(_sp.less(onsample, 1)): + if np.any(np.less(onsample, 1)): raise ValueError("nsample < 1") - if _sp.any(_sp.less(_sp.add(ongood, onbad),onsample)): + if np.any(np.less(np.add(ongood, onbad),onsample)): raise ValueError("ngood + nbad < nsample") return discnmN_array(self.internal_state, rk_hypergeometric, size, ongood, onbad, onsample) @@ -1442,9 +1442,9 @@ PyErr_Clear() op = PyArray_FROM_OTF(p, NPY_DOUBLE, NPY_ALIGNED) - if _sp.any(_sp.less(op, 0.0)): + if np.any(np.less(op, 0.0)): raise ValueError("p < 0.0") - if _sp.any(_sp.greater(op, 1.0)): + if np.any(np.greater(op, 1.0)): raise ValueError("p > 1.0") return discd_array(self.internal_state, rk_logseries, size, op) @@ -1467,8 +1467,8 @@ normal. """ # Check preconditions on arguments - mean = _sp.array(mean) - cov = _sp.array(cov) + mean = np.array(mean) + cov = np.array(cov) if size is None: shape = [] else: @@ -1487,8 +1487,8 @@ # Create a matrix of independent standard normally distributed random # numbers. The matrix has rows with the same length as mean and as # many rows are necessary to form a matrix of shape final_shape. - x = self.standard_normal(_sp.multiply.reduce(final_shape)) - x.shape = (_sp.multiply.reduce(final_shape[0:len(final_shape)-1]), + x = self.standard_normal(np.multiply.reduce(final_shape)) + x.shape = (np.multiply.reduce(final_shape[0:len(final_shape)-1]), mean.shape[0]) # Transform matrix of standard normals into matrix where each row # contains multivariate normals with the desired covariance. @@ -1500,10 +1500,10 @@ from numpy.dual import svd # XXX: we really should be doing this by Cholesky decomposition (u,s,v) = svd(cov) - x = _sp.dot(x*_sp.sqrt(s),v) + x = np.dot(x*np.sqrt(s),v) # The rows of x now have the correct covariance but mean 0. Add # mean to each row. Then each row will have mean mean. - _sp.add(mean,x,x) + np.add(mean,x,x) x.shape = tuple(final_shape) return x @@ -1537,7 +1537,7 @@ else: shape = size + (d,) - multin = _sp.zeros(shape, int) + multin = np.zeros(shape, int) mnarr = multin mnix = mnarr.data i = 0 @@ -1629,7 +1629,7 @@ else: shape = size + (k,) - diric = _sp.zeros(shape, _sp.float64) + diric = np.zeros(shape, np.float64) val_arr = diric val_data= val_arr.data @@ -1688,10 +1688,10 @@ permutation(x) """ - if isinstance(x, (int, _sp.integer)): - arr = _sp.arange(x) + if isinstance(x, (int, np.integer)): + arr = np.arange(x) else: - arr = _sp.array(x) + arr = np.array(x) self.shuffle(arr) return arr From numpy-svn at scipy.org Fri Jul 25 12:43:38 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 25 Jul 2008 11:43:38 -0500 (CDT) Subject: [Numpy-svn] r5525 - trunk/numpy/random/mtrand Message-ID: <20080725164338.14749C7C024@scipy.org> Author: alan.mcintyre Date: 2008-07-25 11:43:32 -0500 (Fri, 25 Jul 2008) New Revision: 5525 Modified: trunk/numpy/random/mtrand/mtrand.c Log: Regenerated mtrand.c after standardizing NumPy import in mtrand.pyx. Modified: trunk/numpy/random/mtrand/mtrand.c =================================================================== --- trunk/numpy/random/mtrand/mtrand.c 2008-07-25 16:09:26 UTC (rev 5524) +++ trunk/numpy/random/mtrand/mtrand.c 2008-07-25 16:43:32 UTC (rev 5525) @@ -1,4 +1,4 @@ -/* Generated by Pyrex 0.9.8.2 on Tue May 20 00:56:24 2008 */ +/* Generated by Pyrex 0.9.8.4 on Fri Jul 25 12:42:18 2008 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -35,8 +35,7 @@ #include "initarray.h" -typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ -typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ +typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ static PyObject *__pyx_m; static PyObject *__pyx_b; @@ -44,10 +43,6 @@ static char *__pyx_filename; static char **__pyx_f; -static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/ - -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*/ @@ -59,12 +54,14 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/ + static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ + static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v); /*proto*/ -static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ @@ -75,6 +72,9 @@ /* Declarations from mtrand */ + +/* Declarations from implementation of mtrand */ + typedef double (*__pyx_t_6mtrand_rk_cont0)(rk_state *); typedef double (*__pyx_t_6mtrand_rk_cont1)(rk_state *,double); @@ -102,65 +102,6 @@ static PyTypeObject *__pyx_ptype_6mtrand_flatiter = 0; static PyTypeObject *__pyx_ptype_6mtrand_broadcast = 0; static PyTypeObject *__pyx_ptype_6mtrand_RandomState = 0; -static PyObject *__pyx_k2; -static PyObject *__pyx_k3; -static PyObject *__pyx_k4; -static PyObject *__pyx_k5; -static PyObject *__pyx_k6; -static PyObject *__pyx_k7; -static PyObject *__pyx_k8; -static PyObject *__pyx_k9; -static PyObject *__pyx_k10; -static PyObject *__pyx_k11; -static PyObject *__pyx_k12; -static PyObject *__pyx_k13; -static PyObject *__pyx_k14; -static PyObject *__pyx_k15; -static PyObject *__pyx_k16; -static PyObject *__pyx_k17; -static PyObject *__pyx_k18; -static PyObject *__pyx_k19; -static PyObject *__pyx_k20; -static PyObject *__pyx_k21; -static PyObject *__pyx_k22; -static PyObject *__pyx_k23; -static PyObject *__pyx_k24; -static PyObject *__pyx_k25; -static PyObject *__pyx_k26; -static PyObject *__pyx_k27; -static PyObject *__pyx_k28; -static PyObject *__pyx_k29; -static PyObject *__pyx_k30; -static PyObject *__pyx_k31; -static PyObject *__pyx_k32; -static PyObject *__pyx_k33; -static PyObject *__pyx_k34; -static PyObject *__pyx_k35; -static PyObject *__pyx_k36; -static PyObject *__pyx_k37; -static PyObject *__pyx_k38; -static PyObject *__pyx_k39; -static PyObject *__pyx_k40; -static PyObject *__pyx_k41; -static PyObject *__pyx_k42; -static PyObject *__pyx_k43; -static PyObject *__pyx_k44; -static PyObject *__pyx_k45; -static PyObject *__pyx_k46; -static PyObject *__pyx_k47; -static PyObject *__pyx_k48; -static PyObject *__pyx_k49; -static PyObject *__pyx_k50; -static PyObject *__pyx_k51; -static PyObject *__pyx_k52; -static PyObject *__pyx_k53; -static PyObject *__pyx_k54; -static PyObject *__pyx_k55; -static PyObject *__pyx_k56; -static PyObject *__pyx_k57; -static PyObject *__pyx_k58; -static PyObject *__pyx_k59; -static PyObject *__pyx_k60; static PyObject *__pyx_f_6mtrand_cont0_array(rk_state *,__pyx_t_6mtrand_rk_cont0,PyObject *); /*proto*/ static PyObject *__pyx_f_6mtrand_cont1_array_sc(rk_state *,__pyx_t_6mtrand_rk_cont1,PyObject *,double); /*proto*/ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state *,__pyx_t_6mtrand_rk_cont1,PyObject *,PyArrayObject *); /*proto*/ @@ -177,63 +118,427 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state *,__pyx_t_6mtrand_rk_discd,PyObject *,PyArrayObject *); /*proto*/ static double __pyx_f_6mtrand_kahan_sum(double *,long); /*proto*/ +static char __pyx_k1[] = "np"; +static char __pyx_k2[] = "empty"; +static char __pyx_k3[] = "float64"; +static char __pyx_k4[] = "size is not compatible with inputs"; +static char __pyx_k5[] = "seed"; +static char __pyx_k6[] = "integer"; +static char __pyx_k7[] = "uint"; +static char __pyx_k8[] = "asarray"; +static char __pyx_k9[] = "uint32"; +static char __pyx_k10[] = "MT19937"; +static char __pyx_k11[] = "algorithm must be 'MT19937'"; +static char __pyx_k12[] = "state must be 624 longs"; +static char __pyx_k13[] = "get_state"; +static char __pyx_k14[] = "set_state"; +static char __pyx_k15[] = "random"; +static char __pyx_k16[] = "__RandomState_ctor"; +static char __pyx_k17[] = "low >= high"; +static char __pyx_k18[] = "subtract"; +static char __pyx_k19[] = "random_sample"; +static char __pyx_k20[] = "size"; +static char __pyx_k21[] = "standard_normal"; +static char __pyx_k22[] = "randint"; +static char __pyx_k23[] = "scale <= 0"; +static char __pyx_k24[] = "any"; +static char __pyx_k25[] = "less_equal"; +static char __pyx_k26[] = "a <= 0"; +static char __pyx_k27[] = "b <= 0"; +static char __pyx_k28[] = "shape <= 0"; +static char __pyx_k29[] = "dfnum <= 0"; +static char __pyx_k30[] = "dfden <= 0"; +static char __pyx_k31[] = "dfnum <= 1"; +static char __pyx_k32[] = "nonc < 0"; +static char __pyx_k33[] = "less"; +static char __pyx_k34[] = "df <= 0"; +static char __pyx_k35[] = "nonc <= 0"; +static char __pyx_k36[] = "df <= 1"; +static char __pyx_k37[] = "kappa < 0"; +static char __pyx_k38[] = "sigma <= 0"; +static char __pyx_k39[] = "sigma <= 0.0"; +static char __pyx_k40[] = "scale <= 0.0"; +static char __pyx_k41[] = "mean <= 0"; +static char __pyx_k42[] = "mean <= 0.0"; +static char __pyx_k43[] = "left > mode"; +static char __pyx_k44[] = "mode > right"; +static char __pyx_k45[] = "left == right"; +static char __pyx_k46[] = "greater"; +static char __pyx_k47[] = "equal"; +static char __pyx_k48[] = "n <= 0"; +static char __pyx_k49[] = "p < 0"; +static char __pyx_k50[] = "p > 1"; +static char __pyx_k51[] = "lam < 0"; +static char __pyx_k52[] = "a <= 1.0"; +static char __pyx_k53[] = "p < 0.0"; +static char __pyx_k54[] = "p > 1.0"; +static char __pyx_k55[] = "ngood < 1"; +static char __pyx_k56[] = "nbad < 1"; +static char __pyx_k57[] = "nsample < 1"; +static char __pyx_k58[] = "ngood + nbad < nsample"; +static char __pyx_k59[] = "add"; +static char __pyx_k60[] = "array"; +static char __pyx_k61[] = "shape"; +static char __pyx_k62[] = "mean must be 1 dimensional"; +static char __pyx_k63[] = "cov must be 2 dimensional and square"; +static char __pyx_k64[] = "mean and cov must have same length"; +static char __pyx_k65[] = "append"; +static char __pyx_k66[] = "multiply"; +static char __pyx_k67[] = "reduce"; +static char __pyx_k68[] = "numpy.dual"; +static char __pyx_k69[] = "svd"; +static char __pyx_k70[] = "dot"; +static char __pyx_k71[] = "sqrt"; +static char __pyx_k72[] = "sum(pvals[:-1]) > 1.0"; +static char __pyx_k73[] = "zeros"; +static char __pyx_k74[] = "copy"; +static char __pyx_k75[] = "arange"; +static char __pyx_k76[] = "shuffle"; +static char __pyx_k77[] = "numpy"; +static char __pyx_k78[] = "_rand"; +static char __pyx_k79[] = "bytes"; +static char __pyx_k80[] = "uniform"; +static char __pyx_k81[] = "rand"; +static char __pyx_k82[] = "randn"; +static char __pyx_k83[] = "random_integers"; +static char __pyx_k84[] = "normal"; +static char __pyx_k85[] = "beta"; +static char __pyx_k86[] = "exponential"; +static char __pyx_k87[] = "standard_exponential"; +static char __pyx_k88[] = "standard_gamma"; +static char __pyx_k89[] = "gamma"; +static char __pyx_k90[] = "f"; +static char __pyx_k91[] = "noncentral_f"; +static char __pyx_k92[] = "chisquare"; +static char __pyx_k93[] = "noncentral_chisquare"; +static char __pyx_k94[] = "standard_cauchy"; +static char __pyx_k95[] = "standard_t"; +static char __pyx_k96[] = "vonmises"; +static char __pyx_k97[] = "pareto"; +static char __pyx_k98[] = "weibull"; +static char __pyx_k99[] = "power"; +static char __pyx_k100[] = "laplace"; +static char __pyx_k101[] = "gumbel"; +static char __pyx_k102[] = "logistic"; +static char __pyx_k103[] = "lognormal"; +static char __pyx_k104[] = "rayleigh"; +static char __pyx_k105[] = "wald"; +static char __pyx_k106[] = "triangular"; +static char __pyx_k107[] = "binomial"; +static char __pyx_k108[] = "negative_binomial"; +static char __pyx_k109[] = "poisson"; +static char __pyx_k110[] = "zipf"; +static char __pyx_k111[] = "geometric"; +static char __pyx_k112[] = "hypergeometric"; +static char __pyx_k113[] = "logseries"; +static char __pyx_k114[] = "multivariate_normal"; +static char __pyx_k115[] = "multinomial"; +static char __pyx_k116[] = "dirichlet"; +static char __pyx_k117[] = "permutation"; -/* Implementation of mtrand */ - - -static PyObject *__pyx_n_numpy; -static PyObject *__pyx_n__sp; +static PyObject *__pyx_n_MT19937; +static PyObject *__pyx_n___RandomState_ctor; static PyObject *__pyx_n__rand; -static PyObject *__pyx_n_seed; -static PyObject *__pyx_n_get_state; -static PyObject *__pyx_n_set_state; -static PyObject *__pyx_n_random_sample; -static PyObject *__pyx_n_randint; +static PyObject *__pyx_n_add; +static PyObject *__pyx_n_any; +static PyObject *__pyx_n_append; +static PyObject *__pyx_n_arange; +static PyObject *__pyx_n_array; +static PyObject *__pyx_n_asarray; +static PyObject *__pyx_n_beta; +static PyObject *__pyx_n_binomial; static PyObject *__pyx_n_bytes; -static PyObject *__pyx_n_uniform; +static PyObject *__pyx_n_chisquare; +static PyObject *__pyx_n_copy; +static PyObject *__pyx_n_dirichlet; +static PyObject *__pyx_n_dot; +static PyObject *__pyx_n_empty; +static PyObject *__pyx_n_equal; +static PyObject *__pyx_n_exponential; +static PyObject *__pyx_n_f; +static PyObject *__pyx_n_float64; +static PyObject *__pyx_n_gamma; +static PyObject *__pyx_n_geometric; +static PyObject *__pyx_n_get_state; +static PyObject *__pyx_n_greater; +static PyObject *__pyx_n_gumbel; +static PyObject *__pyx_n_hypergeometric; +static PyObject *__pyx_n_integer; +static PyObject *__pyx_n_laplace; +static PyObject *__pyx_n_less; +static PyObject *__pyx_n_less_equal; +static PyObject *__pyx_n_logistic; +static PyObject *__pyx_n_lognormal; +static PyObject *__pyx_n_logseries; +static PyObject *__pyx_n_multinomial; +static PyObject *__pyx_n_multiply; +static PyObject *__pyx_n_multivariate_normal; +static PyObject *__pyx_n_negative_binomial; +static PyObject *__pyx_n_noncentral_chisquare; +static PyObject *__pyx_n_noncentral_f; +static PyObject *__pyx_n_normal; +static PyObject *__pyx_n_np; +static PyObject *__pyx_n_numpy; +static PyObject *__pyx_n_pareto; +static PyObject *__pyx_n_permutation; +static PyObject *__pyx_n_poisson; +static PyObject *__pyx_n_power; static PyObject *__pyx_n_rand; +static PyObject *__pyx_n_randint; static PyObject *__pyx_n_randn; +static PyObject *__pyx_n_random; static PyObject *__pyx_n_random_integers; -static PyObject *__pyx_n_standard_normal; -static PyObject *__pyx_n_normal; -static PyObject *__pyx_n_beta; -static PyObject *__pyx_n_exponential; +static PyObject *__pyx_n_random_sample; +static PyObject *__pyx_n_rayleigh; +static PyObject *__pyx_n_reduce; +static PyObject *__pyx_n_seed; +static PyObject *__pyx_n_set_state; +static PyObject *__pyx_n_shape; +static PyObject *__pyx_n_shuffle; +static PyObject *__pyx_n_size; +static PyObject *__pyx_n_sqrt; +static PyObject *__pyx_n_standard_cauchy; static PyObject *__pyx_n_standard_exponential; static PyObject *__pyx_n_standard_gamma; -static PyObject *__pyx_n_gamma; -static PyObject *__pyx_n_f; -static PyObject *__pyx_n_noncentral_f; -static PyObject *__pyx_n_chisquare; -static PyObject *__pyx_n_noncentral_chisquare; -static PyObject *__pyx_n_standard_cauchy; +static PyObject *__pyx_n_standard_normal; static PyObject *__pyx_n_standard_t; +static PyObject *__pyx_n_subtract; +static PyObject *__pyx_n_svd; +static PyObject *__pyx_n_triangular; +static PyObject *__pyx_n_uint; +static PyObject *__pyx_n_uint32; +static PyObject *__pyx_n_uniform; static PyObject *__pyx_n_vonmises; -static PyObject *__pyx_n_pareto; -static PyObject *__pyx_n_weibull; -static PyObject *__pyx_n_power; -static PyObject *__pyx_n_laplace; -static PyObject *__pyx_n_gumbel; -static PyObject *__pyx_n_logistic; -static PyObject *__pyx_n_lognormal; -static PyObject *__pyx_n_rayleigh; static PyObject *__pyx_n_wald; -static PyObject *__pyx_n_triangular; -static PyObject *__pyx_n_binomial; -static PyObject *__pyx_n_negative_binomial; -static PyObject *__pyx_n_poisson; +static PyObject *__pyx_n_weibull; +static PyObject *__pyx_n_zeros; static PyObject *__pyx_n_zipf; -static PyObject *__pyx_n_geometric; -static PyObject *__pyx_n_hypergeometric; -static PyObject *__pyx_n_logseries; -static PyObject *__pyx_n_multivariate_normal; -static PyObject *__pyx_n_multinomial; -static PyObject *__pyx_n_dirichlet; -static PyObject *__pyx_n_shuffle; -static PyObject *__pyx_n_permutation; -static PyObject *__pyx_n_empty; -static PyObject *__pyx_n_float64; +static PyObject *__pyx_k4p; +static PyObject *__pyx_k11p; +static PyObject *__pyx_k12p; +static PyObject *__pyx_k17p; +static PyObject *__pyx_k23p; +static PyObject *__pyx_k26p; +static PyObject *__pyx_k27p; +static PyObject *__pyx_k28p; +static PyObject *__pyx_k29p; +static PyObject *__pyx_k30p; +static PyObject *__pyx_k31p; +static PyObject *__pyx_k32p; +static PyObject *__pyx_k34p; +static PyObject *__pyx_k35p; +static PyObject *__pyx_k36p; +static PyObject *__pyx_k37p; +static PyObject *__pyx_k38p; +static PyObject *__pyx_k39p; +static PyObject *__pyx_k40p; +static PyObject *__pyx_k41p; +static PyObject *__pyx_k42p; +static PyObject *__pyx_k43p; +static PyObject *__pyx_k44p; +static PyObject *__pyx_k45p; +static PyObject *__pyx_k48p; +static PyObject *__pyx_k49p; +static PyObject *__pyx_k50p; +static PyObject *__pyx_k51p; +static PyObject *__pyx_k52p; +static PyObject *__pyx_k53p; +static PyObject *__pyx_k54p; +static PyObject *__pyx_k55p; +static PyObject *__pyx_k56p; +static PyObject *__pyx_k57p; +static PyObject *__pyx_k58p; +static PyObject *__pyx_k62p; +static PyObject *__pyx_k63p; +static PyObject *__pyx_k64p; +static PyObject *__pyx_k68p; +static PyObject *__pyx_k72p; +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_MT19937, 1, __pyx_k10, sizeof(__pyx_k10)}, + {&__pyx_n___RandomState_ctor, 1, __pyx_k16, sizeof(__pyx_k16)}, + {&__pyx_n__rand, 1, __pyx_k78, sizeof(__pyx_k78)}, + {&__pyx_n_add, 1, __pyx_k59, sizeof(__pyx_k59)}, + {&__pyx_n_any, 1, __pyx_k24, sizeof(__pyx_k24)}, + {&__pyx_n_append, 1, __pyx_k65, sizeof(__pyx_k65)}, + {&__pyx_n_arange, 1, __pyx_k75, sizeof(__pyx_k75)}, + {&__pyx_n_array, 1, __pyx_k60, sizeof(__pyx_k60)}, + {&__pyx_n_asarray, 1, __pyx_k8, sizeof(__pyx_k8)}, + {&__pyx_n_beta, 1, __pyx_k85, sizeof(__pyx_k85)}, + {&__pyx_n_binomial, 1, __pyx_k107, sizeof(__pyx_k107)}, + {&__pyx_n_bytes, 1, __pyx_k79, sizeof(__pyx_k79)}, + {&__pyx_n_chisquare, 1, __pyx_k92, sizeof(__pyx_k92)}, + {&__pyx_n_copy, 1, __pyx_k74, sizeof(__pyx_k74)}, + {&__pyx_n_dirichlet, 1, __pyx_k116, sizeof(__pyx_k116)}, + {&__pyx_n_dot, 1, __pyx_k70, sizeof(__pyx_k70)}, + {&__pyx_n_empty, 1, __pyx_k2, sizeof(__pyx_k2)}, + {&__pyx_n_equal, 1, __pyx_k47, sizeof(__pyx_k47)}, + {&__pyx_n_exponential, 1, __pyx_k86, sizeof(__pyx_k86)}, + {&__pyx_n_f, 1, __pyx_k90, sizeof(__pyx_k90)}, + {&__pyx_n_float64, 1, __pyx_k3, sizeof(__pyx_k3)}, + {&__pyx_n_gamma, 1, __pyx_k89, sizeof(__pyx_k89)}, + {&__pyx_n_geometric, 1, __pyx_k111, sizeof(__pyx_k111)}, + {&__pyx_n_get_state, 1, __pyx_k13, sizeof(__pyx_k13)}, + {&__pyx_n_greater, 1, __pyx_k46, sizeof(__pyx_k46)}, + {&__pyx_n_gumbel, 1, __pyx_k101, sizeof(__pyx_k101)}, + {&__pyx_n_hypergeometric, 1, __pyx_k112, sizeof(__pyx_k112)}, + {&__pyx_n_integer, 1, __pyx_k6, sizeof(__pyx_k6)}, + {&__pyx_n_laplace, 1, __pyx_k100, sizeof(__pyx_k100)}, + {&__pyx_n_less, 1, __pyx_k33, sizeof(__pyx_k33)}, + {&__pyx_n_less_equal, 1, __pyx_k25, sizeof(__pyx_k25)}, + {&__pyx_n_logistic, 1, __pyx_k102, sizeof(__pyx_k102)}, + {&__pyx_n_lognormal, 1, __pyx_k103, sizeof(__pyx_k103)}, + {&__pyx_n_logseries, 1, __pyx_k113, sizeof(__pyx_k113)}, + {&__pyx_n_multinomial, 1, __pyx_k115, sizeof(__pyx_k115)}, + {&__pyx_n_multiply, 1, __pyx_k66, sizeof(__pyx_k66)}, + {&__pyx_n_multivariate_normal, 1, __pyx_k114, sizeof(__pyx_k114)}, + {&__pyx_n_negative_binomial, 1, __pyx_k108, sizeof(__pyx_k108)}, + {&__pyx_n_noncentral_chisquare, 1, __pyx_k93, sizeof(__pyx_k93)}, + {&__pyx_n_noncentral_f, 1, __pyx_k91, sizeof(__pyx_k91)}, + {&__pyx_n_normal, 1, __pyx_k84, sizeof(__pyx_k84)}, + {&__pyx_n_np, 1, __pyx_k1, sizeof(__pyx_k1)}, + {&__pyx_n_numpy, 1, __pyx_k77, sizeof(__pyx_k77)}, + {&__pyx_n_pareto, 1, __pyx_k97, sizeof(__pyx_k97)}, + {&__pyx_n_permutation, 1, __pyx_k117, sizeof(__pyx_k117)}, + {&__pyx_n_poisson, 1, __pyx_k109, sizeof(__pyx_k109)}, + {&__pyx_n_power, 1, __pyx_k99, sizeof(__pyx_k99)}, + {&__pyx_n_rand, 1, __pyx_k81, sizeof(__pyx_k81)}, + {&__pyx_n_randint, 1, __pyx_k22, sizeof(__pyx_k22)}, + {&__pyx_n_randn, 1, __pyx_k82, sizeof(__pyx_k82)}, + {&__pyx_n_random, 1, __pyx_k15, sizeof(__pyx_k15)}, + {&__pyx_n_random_integers, 1, __pyx_k83, sizeof(__pyx_k83)}, + {&__pyx_n_random_sample, 1, __pyx_k19, sizeof(__pyx_k19)}, + {&__pyx_n_rayleigh, 1, __pyx_k104, sizeof(__pyx_k104)}, + {&__pyx_n_reduce, 1, __pyx_k67, sizeof(__pyx_k67)}, + {&__pyx_n_seed, 1, __pyx_k5, sizeof(__pyx_k5)}, + {&__pyx_n_set_state, 1, __pyx_k14, sizeof(__pyx_k14)}, + {&__pyx_n_shape, 1, __pyx_k61, sizeof(__pyx_k61)}, + {&__pyx_n_shuffle, 1, __pyx_k76, sizeof(__pyx_k76)}, + {&__pyx_n_size, 1, __pyx_k20, sizeof(__pyx_k20)}, + {&__pyx_n_sqrt, 1, __pyx_k71, sizeof(__pyx_k71)}, + {&__pyx_n_standard_cauchy, 1, __pyx_k94, sizeof(__pyx_k94)}, + {&__pyx_n_standard_exponential, 1, __pyx_k87, sizeof(__pyx_k87)}, + {&__pyx_n_standard_gamma, 1, __pyx_k88, sizeof(__pyx_k88)}, + {&__pyx_n_standard_normal, 1, __pyx_k21, sizeof(__pyx_k21)}, + {&__pyx_n_standard_t, 1, __pyx_k95, sizeof(__pyx_k95)}, + {&__pyx_n_subtract, 1, __pyx_k18, sizeof(__pyx_k18)}, + {&__pyx_n_svd, 1, __pyx_k69, sizeof(__pyx_k69)}, + {&__pyx_n_triangular, 1, __pyx_k106, sizeof(__pyx_k106)}, + {&__pyx_n_uint, 1, __pyx_k7, sizeof(__pyx_k7)}, + {&__pyx_n_uint32, 1, __pyx_k9, sizeof(__pyx_k9)}, + {&__pyx_n_uniform, 1, __pyx_k80, sizeof(__pyx_k80)}, + {&__pyx_n_vonmises, 1, __pyx_k96, sizeof(__pyx_k96)}, + {&__pyx_n_wald, 1, __pyx_k105, sizeof(__pyx_k105)}, + {&__pyx_n_weibull, 1, __pyx_k98, sizeof(__pyx_k98)}, + {&__pyx_n_zeros, 1, __pyx_k73, sizeof(__pyx_k73)}, + {&__pyx_n_zipf, 1, __pyx_k110, sizeof(__pyx_k110)}, + {&__pyx_k4p, 0, __pyx_k4, sizeof(__pyx_k4)}, + {&__pyx_k11p, 0, __pyx_k11, sizeof(__pyx_k11)}, + {&__pyx_k12p, 0, __pyx_k12, sizeof(__pyx_k12)}, + {&__pyx_k17p, 0, __pyx_k17, sizeof(__pyx_k17)}, + {&__pyx_k23p, 0, __pyx_k23, sizeof(__pyx_k23)}, + {&__pyx_k26p, 0, __pyx_k26, sizeof(__pyx_k26)}, + {&__pyx_k27p, 0, __pyx_k27, sizeof(__pyx_k27)}, + {&__pyx_k28p, 0, __pyx_k28, sizeof(__pyx_k28)}, + {&__pyx_k29p, 0, __pyx_k29, sizeof(__pyx_k29)}, + {&__pyx_k30p, 0, __pyx_k30, sizeof(__pyx_k30)}, + {&__pyx_k31p, 0, __pyx_k31, sizeof(__pyx_k31)}, + {&__pyx_k32p, 0, __pyx_k32, sizeof(__pyx_k32)}, + {&__pyx_k34p, 0, __pyx_k34, sizeof(__pyx_k34)}, + {&__pyx_k35p, 0, __pyx_k35, sizeof(__pyx_k35)}, + {&__pyx_k36p, 0, __pyx_k36, sizeof(__pyx_k36)}, + {&__pyx_k37p, 0, __pyx_k37, sizeof(__pyx_k37)}, + {&__pyx_k38p, 0, __pyx_k38, sizeof(__pyx_k38)}, + {&__pyx_k39p, 0, __pyx_k39, sizeof(__pyx_k39)}, + {&__pyx_k40p, 0, __pyx_k40, sizeof(__pyx_k40)}, + {&__pyx_k41p, 0, __pyx_k41, sizeof(__pyx_k41)}, + {&__pyx_k42p, 0, __pyx_k42, sizeof(__pyx_k42)}, + {&__pyx_k43p, 0, __pyx_k43, sizeof(__pyx_k43)}, + {&__pyx_k44p, 0, __pyx_k44, sizeof(__pyx_k44)}, + {&__pyx_k45p, 0, __pyx_k45, sizeof(__pyx_k45)}, + {&__pyx_k48p, 0, __pyx_k48, sizeof(__pyx_k48)}, + {&__pyx_k49p, 0, __pyx_k49, sizeof(__pyx_k49)}, + {&__pyx_k50p, 0, __pyx_k50, sizeof(__pyx_k50)}, + {&__pyx_k51p, 0, __pyx_k51, sizeof(__pyx_k51)}, + {&__pyx_k52p, 0, __pyx_k52, sizeof(__pyx_k52)}, + {&__pyx_k53p, 0, __pyx_k53, sizeof(__pyx_k53)}, + {&__pyx_k54p, 0, __pyx_k54, sizeof(__pyx_k54)}, + {&__pyx_k55p, 0, __pyx_k55, sizeof(__pyx_k55)}, + {&__pyx_k56p, 0, __pyx_k56, sizeof(__pyx_k56)}, + {&__pyx_k57p, 0, __pyx_k57, sizeof(__pyx_k57)}, + {&__pyx_k58p, 0, __pyx_k58, sizeof(__pyx_k58)}, + {&__pyx_k62p, 0, __pyx_k62, sizeof(__pyx_k62)}, + {&__pyx_k63p, 0, __pyx_k63, sizeof(__pyx_k63)}, + {&__pyx_k64p, 0, __pyx_k64, sizeof(__pyx_k64)}, + {&__pyx_k68p, 0, __pyx_k68, sizeof(__pyx_k68)}, + {&__pyx_k72p, 0, __pyx_k72, sizeof(__pyx_k72)}, + {0, 0, 0, 0} +}; + +static PyObject *__pyx_d1; +static PyObject *__pyx_d2; +static PyObject *__pyx_d3; +static PyObject *__pyx_d4; +static PyObject *__pyx_d5; +static PyObject *__pyx_d6; +static PyObject *__pyx_d7; +static PyObject *__pyx_d8; +static PyObject *__pyx_d9; +static PyObject *__pyx_d10; +static PyObject *__pyx_d11; +static PyObject *__pyx_d12; +static PyObject *__pyx_d13; +static PyObject *__pyx_d14; +static PyObject *__pyx_d15; +static PyObject *__pyx_d16; +static PyObject *__pyx_d17; +static PyObject *__pyx_d18; +static PyObject *__pyx_d19; +static PyObject *__pyx_d20; +static PyObject *__pyx_d21; +static PyObject *__pyx_d22; +static PyObject *__pyx_d23; +static PyObject *__pyx_d24; +static PyObject *__pyx_d25; +static PyObject *__pyx_d26; +static PyObject *__pyx_d27; +static PyObject *__pyx_d28; +static PyObject *__pyx_d29; +static PyObject *__pyx_d30; +static PyObject *__pyx_d31; +static PyObject *__pyx_d32; +static PyObject *__pyx_d33; +static PyObject *__pyx_d34; +static PyObject *__pyx_d35; +static PyObject *__pyx_d36; +static PyObject *__pyx_d37; +static PyObject *__pyx_d38; +static PyObject *__pyx_d39; +static PyObject *__pyx_d40; +static PyObject *__pyx_d41; +static PyObject *__pyx_d42; +static PyObject *__pyx_d43; +static PyObject *__pyx_d44; +static PyObject *__pyx_d45; +static PyObject *__pyx_d46; +static PyObject *__pyx_d47; +static PyObject *__pyx_d48; +static PyObject *__pyx_d49; +static PyObject *__pyx_d50; +static PyObject *__pyx_d51; +static PyObject *__pyx_d52; +static PyObject *__pyx_d53; +static PyObject *__pyx_d54; +static PyObject *__pyx_d55; +static PyObject *__pyx_d56; +static PyObject *__pyx_d57; +static PyObject *__pyx_d58; +static PyObject *__pyx_d59; + + +/* Implementation of mtrand */ + static PyObject *__pyx_f_6mtrand_cont0_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_cont0 __pyx_v_func,PyObject *__pyx_v_size) { double *__pyx_v_array_data; PyArrayObject *arrayObject; @@ -247,7 +552,7 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":130 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":130 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;} @@ -258,11 +563,11 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":133 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":133 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} @@ -273,23 +578,23 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":134 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":134 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":135 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":135 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":136 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":136 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":138 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":138 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -323,7 +628,7 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":147 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":147 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; goto __pyx_L1;} @@ -334,11 +639,11 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":150 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":150 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} @@ -349,23 +654,23 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":151 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":151 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":152 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":152 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":153 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":153 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":155 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":155 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -386,10 +691,6 @@ return __pyx_r; } -static PyObject *__pyx_k61p; - -static char __pyx_k61[] = "size is not compatible with inputs"; - static PyObject *__pyx_f_6mtrand_cont1_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_cont1 __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_oa) { double *__pyx_v_array_data; double *__pyx_v_oa_data; @@ -410,48 +711,48 @@ __pyx_v_itera = ((PyArrayIterObject *)Py_None); Py_INCREF(Py_None); __pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":166 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":166 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":167 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":167 */ __pyx_2 = PyArray_SimpleNew(__pyx_v_oa->nd,__pyx_v_oa->dimensions,NPY_DOUBLE); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":168 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":168 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":169 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":169 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":170 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":170 */ __pyx_2 = PyArray_IterNew(((PyObject *)__pyx_v_oa)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayIterObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_itera)); __pyx_v_itera = ((PyArrayIterObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":171 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":171 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":172 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":172 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(((double *)__pyx_v_itera->dataptr)[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":173 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":173 */ PyArray_ITER_NEXT(__pyx_v_itera); } goto __pyx_L2; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":175 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":175 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} @@ -462,27 +763,27 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":176 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":176 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":177 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":177 */ __pyx_3 = PyArray_MultiIterNew(2,((void *)arrayObject),((void *)__pyx_v_oa)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":179 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":179 */ __pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject)); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;} - Py_INCREF(__pyx_k61p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k61p); + Py_INCREF(__pyx_k4p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p); __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_4, 0, 0); @@ -492,23 +793,23 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":181 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":181 */ __pyx_5 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":182 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":182 */ __pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":183 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":183 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":184 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":184 */ PyArray_MultiIter_NEXTi(__pyx_v_multi,1); } } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":185 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":185 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -543,7 +844,7 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":194 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":194 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;} @@ -554,11 +855,11 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":197 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":197 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} @@ -569,23 +870,23 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":198 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":198 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":199 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":199 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":200 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":200 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":202 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":202 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -606,10 +907,6 @@ return __pyx_r; } -static PyObject *__pyx_k62p; - -static char __pyx_k62[] = "size is not compatible with inputs"; - static PyObject *__pyx_f_6mtrand_cont2_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_cont2 __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_oa,PyArrayObject *__pyx_v_ob) { double *__pyx_v_array_data; double *__pyx_v_oa_data; @@ -629,52 +926,52 @@ arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":215 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":215 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":216 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":216 */ __pyx_2 = PyArray_MultiIterNew(2,((void *)__pyx_v_oa),((void *)__pyx_v_ob)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":217 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":217 */ __pyx_2 = PyArray_SimpleNew(__pyx_v_multi->nd,__pyx_v_multi->dimensions,NPY_DOUBLE); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":218 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":218 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":219 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":219 */ __pyx_3 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":220 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":220 */ __pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,0)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":221 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":221 */ __pyx_v_ob_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":222 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":222 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]),(__pyx_v_ob_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":223 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":223 */ PyArray_MultiIter_NEXT(__pyx_v_multi); } goto __pyx_L2; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":225 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":225 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} @@ -685,27 +982,27 @@ __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5))); + Py_INCREF(__pyx_5); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_5); Py_DECREF(__pyx_5); __pyx_5 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":226 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":226 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":227 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":227 */ __pyx_4 = PyArray_MultiIterNew(3,((void *)arrayObject),((void *)__pyx_v_oa),((void *)__pyx_v_ob)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":228 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":228 */ __pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject)); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;} - Py_INCREF(__pyx_k62p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k62p); + Py_INCREF(__pyx_k4p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -715,29 +1012,29 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":230 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":230 */ __pyx_3 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":231 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":231 */ __pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":232 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":232 */ __pyx_v_ob_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,2)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":233 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":233 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]),(__pyx_v_ob_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":234 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":234 */ PyArray_MultiIter_NEXTi(__pyx_v_multi,1); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":235 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":235 */ PyArray_MultiIter_NEXTi(__pyx_v_multi,2); } } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":236 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":236 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -772,7 +1069,7 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":246 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":246 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} @@ -783,11 +1080,11 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":249 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":249 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} @@ -798,23 +1095,23 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":250 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":250 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":251 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":251 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":252 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":252 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":254 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":254 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -835,10 +1132,6 @@ return __pyx_r; } -static PyObject *__pyx_k63p; - -static char __pyx_k63[] = "size is not compatible with inputs"; - static PyObject *__pyx_f_6mtrand_cont3_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_cont3 __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_oa,PyArrayObject *__pyx_v_ob,PyArrayObject *__pyx_v_oc) { double *__pyx_v_array_data; double *__pyx_v_oa_data; @@ -860,55 +1153,55 @@ arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":268 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":268 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":269 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":269 */ __pyx_2 = PyArray_MultiIterNew(3,((void *)__pyx_v_oa),((void *)__pyx_v_ob),((void *)__pyx_v_oc)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":270 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":270 */ __pyx_2 = PyArray_SimpleNew(__pyx_v_multi->nd,__pyx_v_multi->dimensions,NPY_DOUBLE); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":271 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":271 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":272 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":272 */ __pyx_3 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":273 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":273 */ __pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,0)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":274 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":274 */ __pyx_v_ob_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":275 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":275 */ __pyx_v_oc_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,2)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":276 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":276 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]),(__pyx_v_ob_data[0]),(__pyx_v_oc_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":277 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":277 */ PyArray_MultiIter_NEXT(__pyx_v_multi); } goto __pyx_L2; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":279 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":279 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} @@ -919,27 +1212,27 @@ __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5))); + Py_INCREF(__pyx_5); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_5); Py_DECREF(__pyx_5); __pyx_5 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":280 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":280 */ __pyx_v_array_data = ((double *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":281 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":281 */ __pyx_4 = PyArray_MultiIterNew(4,((void *)arrayObject),((void *)__pyx_v_oa),((void *)__pyx_v_ob),((void *)__pyx_v_oc)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":283 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":283 */ __pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject)); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;} - Py_INCREF(__pyx_k63p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k63p); + Py_INCREF(__pyx_k4p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -949,29 +1242,29 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":285 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":285 */ __pyx_3 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":286 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":286 */ __pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":287 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":287 */ __pyx_v_ob_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,2)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":288 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":288 */ __pyx_v_oc_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,3)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":289 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":289 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0]),(__pyx_v_ob_data[0]),(__pyx_v_oc_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":290 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":290 */ PyArray_MultiIter_NEXT(__pyx_v_multi); } } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":291 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":291 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -1007,7 +1300,7 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":299 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":299 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; goto __pyx_L1;} @@ -1018,8 +1311,8 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":302 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":302 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;} @@ -1030,23 +1323,23 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":303 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":303 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":304 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":304 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":305 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":305 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":307 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":307 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -1080,7 +1373,7 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":315 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":315 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;} @@ -1091,8 +1384,8 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":318 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":318 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} @@ -1103,23 +1396,23 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":319 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":319 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":320 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":320 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":321 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":321 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":323 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":323 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -1140,10 +1433,6 @@ return __pyx_r; } -static PyObject *__pyx_k64p; - -static char __pyx_k64[] = "size is not compatible with inputs"; - static PyObject *__pyx_f_6mtrand_discnp_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_discnp __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_on,PyArrayObject *__pyx_v_op) { long *__pyx_v_array_data; PyArrayObject *arrayObject; @@ -1163,49 +1452,49 @@ arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":334 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":334 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":335 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":335 */ __pyx_2 = PyArray_MultiIterNew(2,((void *)__pyx_v_on),((void *)__pyx_v_op)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":336 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":336 */ __pyx_2 = PyArray_SimpleNew(__pyx_v_multi->nd,__pyx_v_multi->dimensions,NPY_LONG); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":337 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":337 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":338 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":338 */ __pyx_3 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":339 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":339 */ __pyx_v_on_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,0)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":340 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":340 */ __pyx_v_op_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":341 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":341 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_on_data[0]),(__pyx_v_op_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":342 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":342 */ PyArray_MultiIter_NEXT(__pyx_v_multi); } goto __pyx_L2; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":344 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":344 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} @@ -1216,27 +1505,27 @@ __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5))); + Py_INCREF(__pyx_5); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_5); Py_DECREF(__pyx_5); __pyx_5 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":345 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":345 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":346 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":346 */ __pyx_4 = PyArray_MultiIterNew(3,((void *)arrayObject),((void *)__pyx_v_on),((void *)__pyx_v_op)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":347 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":347 */ __pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject)); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;} - Py_INCREF(__pyx_k64p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k64p); + Py_INCREF(__pyx_k4p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -1246,29 +1535,29 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":349 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":349 */ __pyx_3 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":350 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":350 */ __pyx_v_on_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":351 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":351 */ __pyx_v_op_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,2)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":352 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":352 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_on_data[0]),(__pyx_v_op_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":353 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":353 */ PyArray_MultiIter_NEXTi(__pyx_v_multi,1); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":354 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":354 */ PyArray_MultiIter_NEXTi(__pyx_v_multi,2); } } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":356 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":356 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -1303,7 +1592,7 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":365 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":365 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} @@ -1314,8 +1603,8 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":368 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":368 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} @@ -1326,23 +1615,23 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":369 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":369 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":370 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":370 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":371 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":371 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":373 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":373 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -1363,10 +1652,6 @@ return __pyx_r; } -static PyObject *__pyx_k65p; - -static char __pyx_k65[] = "size is not compatible with inputs"; - static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_discnmN __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_on,PyArrayObject *__pyx_v_om,PyArrayObject *__pyx_v_oN) { long *__pyx_v_array_data; long *__pyx_v_on_data; @@ -1388,52 +1673,52 @@ arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":386 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":386 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":387 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":387 */ __pyx_2 = PyArray_MultiIterNew(3,((void *)__pyx_v_on),((void *)__pyx_v_om),((void *)__pyx_v_oN)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":388 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":388 */ __pyx_2 = PyArray_SimpleNew(__pyx_v_multi->nd,__pyx_v_multi->dimensions,NPY_LONG); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":389 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":389 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":390 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":390 */ __pyx_3 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":391 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":391 */ __pyx_v_on_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,0)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":392 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":392 */ __pyx_v_om_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":393 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":393 */ __pyx_v_oN_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,2)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":394 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":394 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_on_data[0]),(__pyx_v_om_data[0]),(__pyx_v_oN_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":395 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":395 */ PyArray_MultiIter_NEXT(__pyx_v_multi); } goto __pyx_L2; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":397 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":397 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;} @@ -1444,27 +1729,27 @@ __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5))); + Py_INCREF(__pyx_5); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_5); Py_DECREF(__pyx_5); __pyx_5 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":398 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":398 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":399 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":399 */ __pyx_4 = PyArray_MultiIterNew(4,((void *)arrayObject),((void *)__pyx_v_on),((void *)__pyx_v_om),((void *)__pyx_v_oN)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":401 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":401 */ __pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject)); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;} - Py_INCREF(__pyx_k65p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k65p); + Py_INCREF(__pyx_k4p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -1474,29 +1759,29 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":403 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":403 */ __pyx_3 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":404 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":404 */ __pyx_v_on_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":405 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":405 */ __pyx_v_om_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,2)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":406 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":406 */ __pyx_v_oN_data = ((long *)PyArray_MultiIter_DATA(__pyx_v_multi,3)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":407 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":407 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_on_data[0]),(__pyx_v_om_data[0]),(__pyx_v_oN_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":408 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":408 */ PyArray_MultiIter_NEXT(__pyx_v_multi); } } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":410 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":410 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -1532,7 +1817,7 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":418 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":418 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; goto __pyx_L1;} @@ -1543,8 +1828,8 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":421 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":421 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;} @@ -1555,23 +1840,23 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":422 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":422 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":423 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":423 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":424 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":424 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":426 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":426 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -1592,10 +1877,6 @@ return __pyx_r; } -static PyObject *__pyx_k66p; - -static char __pyx_k66[] = "size is not compatible with inputs"; - static PyObject *__pyx_f_6mtrand_discd_array(rk_state *__pyx_v_state,__pyx_t_6mtrand_rk_discd __pyx_v_func,PyObject *__pyx_v_size,PyArrayObject *__pyx_v_oa) { long *__pyx_v_array_data; double *__pyx_v_oa_data; @@ -1616,45 +1897,45 @@ __pyx_v_multi = ((PyArrayMultiIterObject *)Py_None); Py_INCREF(Py_None); __pyx_v_itera = ((PyArrayIterObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":437 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":437 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":438 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":438 */ __pyx_2 = PyArray_SimpleNew(__pyx_v_oa->nd,__pyx_v_oa->dimensions,NPY_LONG); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":439 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":439 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":440 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":440 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":441 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":441 */ __pyx_2 = PyArray_IterNew(((PyObject *)__pyx_v_oa)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayIterObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_itera)); __pyx_v_itera = ((PyArrayIterObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":442 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":442 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":443 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":443 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(((double *)__pyx_v_itera->dataptr)[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":444 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":444 */ PyArray_ITER_NEXT(__pyx_v_itera); } goto __pyx_L2; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":446 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":446 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;} @@ -1665,27 +1946,27 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(__pyx_4); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":447 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":447 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":448 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":448 */ __pyx_3 = PyArray_MultiIterNew(2,((void *)arrayObject),((void *)__pyx_v_oa)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayMultiIterObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_multi)); __pyx_v_multi = ((PyArrayMultiIterObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":449 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":449 */ __pyx_1 = (__pyx_v_multi->size != PyArray_SIZE(arrayObject)); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} - Py_INCREF(__pyx_k66p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k66p); + Py_INCREF(__pyx_k4p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k4p); __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_4, 0, 0); @@ -1695,23 +1976,23 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":451 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":451 */ __pyx_5 = __pyx_v_multi->size; for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":452 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":452 */ __pyx_v_oa_data = ((double *)PyArray_MultiIter_DATA(__pyx_v_multi,1)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":453 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":453 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,(__pyx_v_oa_data[0])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":454 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":454 */ PyArray_MultiIter_NEXTi(__pyx_v_multi,1); } } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":455 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":455 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -1741,29 +2022,29 @@ long __pyx_v_i; double __pyx_r; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":460 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":460 */ __pyx_v_sum = (__pyx_v_darr[0]); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":461 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":461 */ __pyx_v_c = 0.0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":462 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":462 */ for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":463 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":463 */ __pyx_v_y = ((__pyx_v_darr[__pyx_v_i]) - __pyx_v_c); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":464 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":464 */ __pyx_v_t = (__pyx_v_sum + __pyx_v_y); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":465 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":465 */ __pyx_v_c = ((__pyx_v_t - __pyx_v_sum) - __pyx_v_y); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":466 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":466 */ __pyx_v_sum = __pyx_v_t; } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":467 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":467 */ __pyx_r = __pyx_v_sum; goto __pyx_L0; @@ -1780,15 +2061,15 @@ PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; static char *__pyx_argnames[] = {"seed",0}; - __pyx_v_seed = __pyx_k2; + __pyx_v_seed = __pyx_d1; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_seed)) return -1; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_seed); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":490 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":490 */ ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = ((rk_state *)PyMem_Malloc((sizeof(rk_state)))); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":492 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":492 */ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} Py_INCREF(__pyx_v_seed); @@ -1819,10 +2100,10 @@ __pyx_1 = (((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state != NULL); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":496 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":496 */ PyMem_Free(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":497 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":497 */ ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = NULL; goto __pyx_L2; } @@ -1831,8 +2112,6 @@ Py_DECREF(__pyx_v_self); } -static PyObject *__pyx_n_integer; - static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_seed[] = "Seed the generator.\n\n seed(seed=None)\n\n seed can be an integer, an array (or other sequence) of integers of any\n length, or None. If seed is None, then RandomState will try to read data\n from /dev/urandom (or the Windows analogue) if available or seed from\n the clock otherwise.\n "; static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -1846,14 +2125,14 @@ PyObject *__pyx_3 = 0; unsigned long __pyx_4; static char *__pyx_argnames[] = {"seed",0}; - __pyx_v_seed = __pyx_k3; + __pyx_v_seed = __pyx_d2; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_seed)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_seed); arrayObject_obj = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_iseed = Py_None; Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":511 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":511 */ __pyx_1 = __pyx_v_seed == Py_None; if (__pyx_1) { __pyx_v_errcode = rk_randomseed(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); @@ -1871,14 +2150,14 @@ rk_seed(__pyx_4,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); goto __pyx_L2; } - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_integer); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_1 = PyObject_IsInstance(__pyx_v_seed,__pyx_3); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":516 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":516 */ __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; goto __pyx_L1;} Py_INCREF(__pyx_v_seed); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed); @@ -1888,21 +2167,21 @@ __pyx_v_iseed = __pyx_3; __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":517 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":517 */ __pyx_4 = PyInt_AsUnsignedLongMask(__pyx_v_iseed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;} rk_seed(__pyx_4,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); goto __pyx_L2; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":519 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":519 */ __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_seed,NPY_LONG,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)arrayObject_obj)); arrayObject_obj = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":520 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":520 */ init_by_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,((unsigned long *)arrayObject_obj->data),(arrayObject_obj->dimensions[0])); } __pyx_L2:; @@ -1922,12 +2201,6 @@ return __pyx_r; } -static PyObject *__pyx_n_uint; -static PyObject *__pyx_n_asarray; -static PyObject *__pyx_n_uint32; -static PyObject *__pyx_n_MT19937; - - static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_get_state[] = "Return a tuple representing the internal state of the generator.\n\n get_state() -> (\'MT19937\', int key[624], int pos, int has_gauss, float cached_gaussian)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -1942,12 +2215,12 @@ Py_INCREF(__pyx_v_self); arrayObject_state = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":529 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":529 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_uint); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} @@ -1958,19 +2231,19 @@ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_INCREF(__pyx_1); Py_DECREF(((PyObject *)arrayObject_state)); arrayObject_state = ((PyArrayObject *)__pyx_1); Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":530 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":530 */ memcpy(arrayObject_state->data,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,(624 * (sizeof(long)))); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":531 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":531 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_asarray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;} __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_uint32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;} @@ -1981,12 +2254,12 @@ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)arrayObject_state)); arrayObject_state = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":532 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":532 */ __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; goto __pyx_L1;} __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->has_gauss); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; goto __pyx_L1;} __pyx_4 = PyFloat_FromDouble(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->gauss); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; goto __pyx_L1;} @@ -2020,12 +2293,6 @@ return __pyx_r; } -static PyObject *__pyx_k69p; -static PyObject *__pyx_k70p; - -static char __pyx_k69[] = "algorithm must be 'MT19937'"; -static char __pyx_k70[] = "state must be 624 longs"; - static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_set_state[] = "Set the state from a tuple.\n\n state = (\'MT19937\', int key[624], int pos, int has_gauss, float cached_gaussian)\n\n For backwards compatibility, the following form is also accepted\n although it is missing some information about the cached Gaussian value.\n\n state = (\'MT19937\', int key[624], int pos)\n\n set_state(state)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -2054,19 +2321,19 @@ __pyx_v_has_gauss = Py_None; Py_INCREF(Py_None); __pyx_v_cached_gaussian = Py_None; Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":549 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":549 */ __pyx_1 = __Pyx_GetItemInt(__pyx_v_state, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; goto __pyx_L1;} Py_DECREF(__pyx_v_algorithm_name); __pyx_v_algorithm_name = __pyx_1; __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":550 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":550 */ if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; goto __pyx_L1;} __pyx_2 = __pyx_2 != 0; if (__pyx_2) { __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;} - Py_INCREF(__pyx_k69p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k69p); + Py_INCREF(__pyx_k11p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k11p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -2076,7 +2343,7 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":552 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":552 */ __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;} __pyx_3 = PyObject_GetIter(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; @@ -2091,18 +2358,18 @@ if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":553 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":553 */ __pyx_4 = PyObject_Length(__pyx_v_state); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;} __pyx_2 = (__pyx_4 == 3); if (__pyx_2) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":554 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":554 */ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; goto __pyx_L1;} Py_DECREF(__pyx_v_has_gauss); __pyx_v_has_gauss = __pyx_1; __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":555 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":555 */ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; goto __pyx_L1;} Py_DECREF(__pyx_v_cached_gaussian); __pyx_v_cached_gaussian = __pyx_3; @@ -2126,10 +2393,10 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":558 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":558 */ /*try:*/ { __pyx_1 = PyArray_ContiguousFromObject(__pyx_v_key,NPY_ULONG,1,1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L4;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_INCREF(__pyx_1); Py_DECREF(((PyObject *)arrayObject_obj)); arrayObject_obj = ((PyArrayObject *)__pyx_1); Py_DECREF(__pyx_1); __pyx_1 = 0; @@ -2139,13 +2406,13 @@ Py_XDECREF(__pyx_3); __pyx_3 = 0; Py_XDECREF(__pyx_1); __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":560 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":560 */ __pyx_2 = PyErr_ExceptionMatches(PyExc_TypeError); if (__pyx_2) { __Pyx_AddTraceback("mtrand.set_state"); if (__Pyx_GetException(&__pyx_3, &__pyx_1, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; goto __pyx_L1;} __pyx_6 = PyArray_ContiguousFromObject(__pyx_v_key,NPY_LONG,1,1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_6))); + Py_INCREF(__pyx_6); Py_DECREF(((PyObject *)arrayObject_obj)); arrayObject_obj = ((PyArrayObject *)__pyx_6); Py_DECREF(__pyx_6); __pyx_6 = 0; @@ -2157,12 +2424,12 @@ goto __pyx_L1; __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":563 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":563 */ __pyx_2 = ((arrayObject_obj->dimensions[0]) != 624); if (__pyx_2) { __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;} - Py_INCREF(__pyx_k70p); - PyTuple_SET_ITEM(__pyx_6, 0, __pyx_k70p); + Py_INCREF(__pyx_k12p); + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_k12p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -2172,17 +2439,17 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":565 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":565 */ memcpy(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,arrayObject_obj->data,(624 * (sizeof(long)))); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":566 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":566 */ ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":567 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":567 */ __pyx_2 = PyInt_AsLong(__pyx_v_has_gauss); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;} ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->has_gauss = __pyx_2; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":568 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":568 */ __pyx_7 = PyFloat_AsDouble(__pyx_v_cached_gaussian); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;} ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->gauss = __pyx_7; @@ -2267,9 +2534,6 @@ return __pyx_r; } -static PyObject *__pyx_n_random; -static PyObject *__pyx_n___RandomState_ctor; - static PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_r; @@ -2280,7 +2544,7 @@ static char *__pyx_argnames[] = {0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;} @@ -2321,7 +2585,7 @@ PyObject *__pyx_r; PyObject *__pyx_1 = 0; static char *__pyx_argnames[] = {"size",0}; - __pyx_v_size = __pyx_k4; + __pyx_v_size = __pyx_d3; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_size); @@ -2349,7 +2613,7 @@ PyObject *__pyx_r; PyObject *__pyx_1 = 0; static char *__pyx_argnames[] = {"size",0}; - __pyx_v_size = __pyx_k5; + __pyx_v_size = __pyx_d4; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_size); @@ -2370,10 +2634,6 @@ return __pyx_r; } -static PyObject *__pyx_k71p; - -static char __pyx_k71[] = "low >= high"; - static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_randint[] = "Return random integers x such that low <= x < high.\n\n randint(low, high=None, size=None) -> random values\n\n If high is None, then 0 <= x < low.\n "; static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -2394,8 +2654,8 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"low","high","size",0}; - __pyx_v_high = __pyx_k6; - __pyx_v_size = __pyx_k7; + __pyx_v_high = __pyx_d5; + __pyx_v_size = __pyx_d6; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|OO", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_low); @@ -2403,39 +2663,39 @@ Py_INCREF(__pyx_v_size); arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":608 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":608 */ __pyx_1 = __pyx_v_high == Py_None; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":609 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":609 */ __pyx_v_lo = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":610 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":610 */ __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; goto __pyx_L1;} __pyx_v_hi = __pyx_2; goto __pyx_L2; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":612 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":612 */ __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;} __pyx_v_lo = __pyx_2; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":613 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":613 */ __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;} __pyx_v_hi = __pyx_2; } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":615 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":615 */ __pyx_v_diff = ((__pyx_v_hi - __pyx_v_lo) - 1); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":616 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":616 */ __pyx_1 = (__pyx_v_diff < 0); if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;} - Py_INCREF(__pyx_k71p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p); + Py_INCREF(__pyx_k17p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k17p); __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); @@ -2445,7 +2705,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":619 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":619 */ __pyx_1 = __pyx_v_size == Py_None; if (__pyx_1) { __pyx_3 = PyInt_FromLong((((long)rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)) + __pyx_v_lo)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; goto __pyx_L1;} @@ -2456,8 +2716,8 @@ } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":622 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":622 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;} @@ -2468,23 +2728,23 @@ __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_5))); + Py_INCREF(__pyx_5); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_5); Py_DECREF(__pyx_5); __pyx_5 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":623 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":623 */ __pyx_v_length = PyArray_SIZE(arrayObject); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":624 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":624 */ __pyx_v_array_data = ((long *)arrayObject->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":625 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":625 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) { (__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + ((long)rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state))); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":627 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":627 */ Py_INCREF(((PyObject *)arrayObject)); __pyx_r = ((PyObject *)arrayObject); goto __pyx_L0; @@ -2521,19 +2781,19 @@ Py_INCREF(__pyx_v_self); __pyx_v_bytestring = Py_None; Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":635 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":635 */ __pyx_1 = PyString_FromStringAndSize(NULL,__pyx_v_length); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;} Py_DECREF(__pyx_v_bytestring); __pyx_v_bytestring = __pyx_1; __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":636 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":636 */ __pyx_v_bytes = PyString_AS_STRING(__pyx_v_bytestring); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":637 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":637 */ rk_fill(__pyx_v_bytes,__pyx_v_length,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":638 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":638 */ Py_INCREF(__pyx_v_bytestring); __pyx_r = __pyx_v_bytestring; goto __pyx_L0; @@ -2550,8 +2810,6 @@ return __pyx_r; } -static PyObject *__pyx_n_subtract; - static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_uniform[] = "Uniform distribution over [low, high).\n\n uniform(low=0.0, high=1.0, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -2570,9 +2828,9 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; static char *__pyx_argnames[] = {"low","high","size",0}; - __pyx_v_low = __pyx_k8; - __pyx_v_high = __pyx_k9; - __pyx_v_size = __pyx_k10; + __pyx_v_low = __pyx_d7; + __pyx_v_high = __pyx_d8; + __pyx_v_size = __pyx_d9; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_low); @@ -2583,13 +2841,13 @@ __pyx_v_odiff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_temp = Py_None; Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":649 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":649 */ __pyx_v_flow = PyFloat_AsDouble(__pyx_v_low); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":650 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":650 */ __pyx_v_fhigh = PyFloat_AsDouble(__pyx_v_high); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":651 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":651 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_flow,(__pyx_v_fhigh - __pyx_v_flow)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; goto __pyx_L1;} @@ -2600,25 +2858,25 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":653 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":653 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":654 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":654 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_low,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_olow)); __pyx_v_olow = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":655 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":655 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_high,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_ohigh)); __pyx_v_ohigh = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":656 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":656 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_subtract); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} @@ -2633,17 +2891,17 @@ __pyx_v_temp = __pyx_4; __pyx_4 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":657 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":657 */ Py_INCREF(__pyx_v_temp); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":659 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":659 */ __pyx_3 = PyArray_EnsureArray(__pyx_v_temp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_odiff)); __pyx_v_odiff = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":660 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":660 */ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_olow,__pyx_v_odiff); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -2669,9 +2927,6 @@ return __pyx_r; } -static PyObject *__pyx_n_size; - - static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_rand[] = "Return an array of the given dimensions which is initialized to\n random numbers from a uniform distribution in the range [0,1).\n\n rand(d0, d1, ..., dn) -> random values\n\n Note: This is a convenience function. If you want an\n interface that takes a tuple as the first argument\n use numpy.random.random_sample(shape_tuple).\n\n "; static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -2807,24 +3062,24 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; static char *__pyx_argnames[] = {"low","high","size",0}; - __pyx_v_high = __pyx_k11; - __pyx_v_size = __pyx_k12; + __pyx_v_high = __pyx_d10; + __pyx_v_size = __pyx_d11; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|OO", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_low); Py_INCREF(__pyx_v_high); Py_INCREF(__pyx_v_size); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":700 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":700 */ __pyx_1 = __pyx_v_high == Py_None; if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":701 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":701 */ Py_INCREF(__pyx_v_low); Py_DECREF(__pyx_v_high); __pyx_v_high = __pyx_v_low; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":702 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":702 */ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; goto __pyx_L1;} Py_DECREF(__pyx_v_low); __pyx_v_low = __pyx_2; @@ -2833,7 +3088,7 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":703 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":703 */ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;} __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;} __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; goto __pyx_L1;} @@ -2875,7 +3130,7 @@ PyObject *__pyx_r; PyObject *__pyx_1 = 0; static char *__pyx_argnames[] = {"size",0}; - __pyx_v_size = __pyx_k13; + __pyx_v_size = __pyx_d12; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_size); @@ -2896,15 +3151,6 @@ return __pyx_r; } -static PyObject *__pyx_n_any; -static PyObject *__pyx_n_less_equal; - -static PyObject *__pyx_k73p; -static PyObject *__pyx_k74p; - -static char __pyx_k73[] = "scale <= 0"; -static char __pyx_k74[] = "scale <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_normal[] = "Normal distribution (mean=loc, stdev=scale).\n\n normal(loc=0.0, scale=1.0, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -2922,9 +3168,9 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"loc","scale","size",0}; - __pyx_v_loc = __pyx_k14; - __pyx_v_scale = __pyx_k15; - __pyx_v_size = __pyx_k16; + __pyx_v_loc = __pyx_d13; + __pyx_v_scale = __pyx_d14; + __pyx_v_size = __pyx_d15; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_loc); @@ -2933,22 +3179,22 @@ __pyx_v_oloc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":721 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":721 */ __pyx_v_floc = PyFloat_AsDouble(__pyx_v_loc); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":722 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":722 */ __pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":723 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":723 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":724 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":724 */ __pyx_1 = (__pyx_v_fscale <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; goto __pyx_L1;} - Py_INCREF(__pyx_k73p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k73p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -2958,7 +3204,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":726 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":726 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -2967,28 +3213,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":728 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":728 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":730 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":730 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oloc)); __pyx_v_oloc = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":731 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":731 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_oscale)); __pyx_v_oscale = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":732 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":732 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} @@ -3010,8 +3256,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} - Py_INCREF(__pyx_k74p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k74p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k23p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -3021,7 +3267,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":734 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":734 */ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -3046,16 +3292,6 @@ return __pyx_r; } -static PyObject *__pyx_k75p; -static PyObject *__pyx_k76p; -static PyObject *__pyx_k77p; -static PyObject *__pyx_k78p; - -static char __pyx_k75[] = "a <= 0"; -static char __pyx_k76[] = "b <= 0"; -static char __pyx_k77[] = "a <= 0"; -static char __pyx_k78[] = "b <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_beta[] = "Beta distribution over [0, 1].\n\n beta(a, b, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3073,7 +3309,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"a","b","size",0}; - __pyx_v_size = __pyx_k17; + __pyx_v_size = __pyx_d16; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_a); @@ -3082,22 +3318,22 @@ __pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_ob = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":744 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":744 */ __pyx_v_fa = PyFloat_AsDouble(__pyx_v_a); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":745 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":745 */ __pyx_v_fb = PyFloat_AsDouble(__pyx_v_b); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":746 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":746 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":747 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":747 */ __pyx_1 = (__pyx_v_fa <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; goto __pyx_L1;} - Py_INCREF(__pyx_k75p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k75p); + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3107,12 +3343,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":749 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":749 */ __pyx_1 = (__pyx_v_fb <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;} - Py_INCREF(__pyx_k76p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k76p); + Py_INCREF(__pyx_k27p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k27p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3122,7 +3358,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":751 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":751 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_fa,__pyx_v_fb); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -3131,28 +3367,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":753 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":753 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":755 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":755 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oa)); __pyx_v_oa = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":756 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":756 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_b,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_ob)); __pyx_v_ob = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":757 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":757 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; goto __pyx_L1;} @@ -3174,8 +3410,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;} - Py_INCREF(__pyx_k77p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k77p); + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k26p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -3185,11 +3421,11 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":759 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":759 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} @@ -3211,8 +3447,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;} - Py_INCREF(__pyx_k78p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k78p); + Py_INCREF(__pyx_k27p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k27p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -3222,7 +3458,7 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":761 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":761 */ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_oa,__pyx_v_ob); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -3247,12 +3483,6 @@ return __pyx_r; } -static PyObject *__pyx_k79p; -static PyObject *__pyx_k80p; - -static char __pyx_k79[] = "scale <= 0"; -static char __pyx_k80[] = "scale <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_exponential[] = "Exponential distribution.\n\n exponential(scale=1.0, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3267,27 +3497,27 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"scale","size",0}; - __pyx_v_scale = __pyx_k18; - __pyx_v_size = __pyx_k19; + __pyx_v_scale = __pyx_d17; + __pyx_v_size = __pyx_d18; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_scale); Py_INCREF(__pyx_v_size); __pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":771 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":771 */ __pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":772 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":772 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":773 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":773 */ __pyx_1 = (__pyx_v_fscale <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;} - Py_INCREF(__pyx_k79p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k79p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3297,7 +3527,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":775 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":775 */ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -3306,21 +3536,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":777 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":777 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":779 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":779 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oscale)); __pyx_v_oscale = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":780 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":780 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} @@ -3342,8 +3572,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;} - Py_INCREF(__pyx_k80p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k80p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3353,7 +3583,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":782 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":782 */ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -3383,7 +3613,7 @@ PyObject *__pyx_r; PyObject *__pyx_1 = 0; static char *__pyx_argnames[] = {"size",0}; - __pyx_v_size = __pyx_k20; + __pyx_v_size = __pyx_d19; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_size); @@ -3404,12 +3634,6 @@ return __pyx_r; } -static PyObject *__pyx_k81p; -static PyObject *__pyx_k82p; - -static char __pyx_k81[] = "shape <= 0"; -static char __pyx_k82[] = "shape <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_standard_gamma[] = "Standard Gamma distribution.\n\n standard_gamma(shape, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3424,26 +3648,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"shape","size",0}; - __pyx_v_size = __pyx_k21; + __pyx_v_size = __pyx_d20; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_shape, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_shape); Py_INCREF(__pyx_v_size); __pyx_v_oshape = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":799 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":799 */ __pyx_v_fshape = PyFloat_AsDouble(__pyx_v_shape); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":800 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":800 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":801 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":801 */ __pyx_1 = (__pyx_v_fshape <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} - Py_INCREF(__pyx_k81p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k81p); + Py_INCREF(__pyx_k28p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k28p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3453,7 +3677,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":803 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":803 */ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_fshape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -3462,21 +3686,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":805 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":805 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":806 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":806 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_shape,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oshape)); __pyx_v_oshape = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":807 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":807 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} @@ -3498,8 +3722,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} - Py_INCREF(__pyx_k82p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k82p); + Py_INCREF(__pyx_k28p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k28p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3509,7 +3733,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":809 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":809 */ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_oshape); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -3532,16 +3756,6 @@ return __pyx_r; } -static PyObject *__pyx_k83p; -static PyObject *__pyx_k84p; -static PyObject *__pyx_k85p; -static PyObject *__pyx_k86p; - -static char __pyx_k83[] = "shape <= 0"; -static char __pyx_k84[] = "scale <= 0"; -static char __pyx_k85[] = "shape <= 0"; -static char __pyx_k86[] = "scale <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_gamma[] = "Gamma distribution.\n\n gamma(shape, scale=1.0, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3559,8 +3773,8 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"shape","scale","size",0}; - __pyx_v_scale = __pyx_k22; - __pyx_v_size = __pyx_k23; + __pyx_v_scale = __pyx_d21; + __pyx_v_size = __pyx_d22; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|OO", __pyx_argnames, &__pyx_v_shape, &__pyx_v_scale, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_shape); @@ -3569,22 +3783,22 @@ __pyx_v_oshape = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":819 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":819 */ __pyx_v_fshape = PyFloat_AsDouble(__pyx_v_shape); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":820 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":820 */ __pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":821 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":821 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":822 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":822 */ __pyx_1 = (__pyx_v_fshape <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} - Py_INCREF(__pyx_k83p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k83p); + Py_INCREF(__pyx_k28p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k28p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3594,12 +3808,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":824 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":824 */ __pyx_1 = (__pyx_v_fscale <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;} - Py_INCREF(__pyx_k84p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k84p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3609,7 +3823,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":826 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":826 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_fshape,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -3618,28 +3832,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":828 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":828 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":829 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":829 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_shape,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oshape)); __pyx_v_oshape = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":830 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":830 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_oscale)); __pyx_v_oscale = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":831 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":831 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} @@ -3661,8 +3875,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} - Py_INCREF(__pyx_k85p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k85p); + Py_INCREF(__pyx_k28p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k28p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -3672,11 +3886,11 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":833 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":833 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; goto __pyx_L1;} @@ -3698,8 +3912,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; goto __pyx_L1;} - Py_INCREF(__pyx_k86p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k86p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k23p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -3709,7 +3923,7 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":835 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":835 */ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_oshape,__pyx_v_oscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -3734,16 +3948,6 @@ return __pyx_r; } -static PyObject *__pyx_k87p; -static PyObject *__pyx_k88p; -static PyObject *__pyx_k89p; -static PyObject *__pyx_k90p; - -static char __pyx_k87[] = "shape <= 0"; -static char __pyx_k88[] = "scale <= 0"; -static char __pyx_k89[] = "dfnum <= 0"; -static char __pyx_k90[] = "dfden <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_f[] = "F distribution.\n\n f(dfnum, dfden, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3761,7 +3965,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"dfnum","dfden","size",0}; - __pyx_v_size = __pyx_k24; + __pyx_v_size = __pyx_d23; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_dfnum); @@ -3770,22 +3974,22 @@ __pyx_v_odfnum = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_odfden = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":845 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":845 */ __pyx_v_fdfnum = PyFloat_AsDouble(__pyx_v_dfnum); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":846 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":846 */ __pyx_v_fdfden = PyFloat_AsDouble(__pyx_v_dfden); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":847 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":847 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":848 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":848 */ __pyx_1 = (__pyx_v_fdfnum <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} - Py_INCREF(__pyx_k87p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k87p); + Py_INCREF(__pyx_k28p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k28p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3795,12 +3999,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":850 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":850 */ __pyx_1 = (__pyx_v_fdfden <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} - Py_INCREF(__pyx_k88p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k88p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -3810,7 +4014,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":852 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":852 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_fdfnum,__pyx_v_fdfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -3819,28 +4023,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":854 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":854 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":856 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":856 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_dfnum,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_odfnum)); __pyx_v_odfnum = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":857 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":857 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_dfden,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_odfden)); __pyx_v_odfden = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":858 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":858 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} @@ -3862,8 +4066,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} - Py_INCREF(__pyx_k89p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k89p); + Py_INCREF(__pyx_k29p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k29p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -3873,11 +4077,11 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":860 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":860 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} @@ -3899,8 +4103,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; goto __pyx_L1;} - Py_INCREF(__pyx_k90p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k90p); + Py_INCREF(__pyx_k30p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k30p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -3910,7 +4114,7 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":862 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":862 */ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_odfnum,__pyx_v_odfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -3935,22 +4139,6 @@ return __pyx_r; } -static PyObject *__pyx_n_less; - -static PyObject *__pyx_k91p; -static PyObject *__pyx_k92p; -static PyObject *__pyx_k93p; -static PyObject *__pyx_k94p; -static PyObject *__pyx_k95p; -static PyObject *__pyx_k96p; - -static char __pyx_k91[] = "dfnum <= 1"; -static char __pyx_k92[] = "dfden <= 0"; -static char __pyx_k93[] = "nonc < 0"; -static char __pyx_k94[] = "dfnum <= 1"; -static char __pyx_k95[] = "dfden <= 0"; -static char __pyx_k96[] = "nonc < 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_noncentral_f[] = "Noncentral F distribution.\n\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3971,7 +4159,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"dfnum","dfden","nonc","size",0}; - __pyx_v_size = __pyx_k25; + __pyx_v_size = __pyx_d24; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO|O", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_nonc, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_dfnum); @@ -3982,25 +4170,25 @@ __pyx_v_odfden = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_ononc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":872 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":872 */ __pyx_v_fdfnum = PyFloat_AsDouble(__pyx_v_dfnum); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":873 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":873 */ __pyx_v_fdfden = PyFloat_AsDouble(__pyx_v_dfden); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":874 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":874 */ __pyx_v_fnonc = PyFloat_AsDouble(__pyx_v_nonc); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":875 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":875 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":876 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":876 */ __pyx_1 = (__pyx_v_fdfnum <= 1); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; goto __pyx_L1;} - Py_INCREF(__pyx_k91p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k91p); + Py_INCREF(__pyx_k31p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k31p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4010,12 +4198,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":878 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":878 */ __pyx_1 = (__pyx_v_fdfden <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; goto __pyx_L1;} - Py_INCREF(__pyx_k92p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k92p); + Py_INCREF(__pyx_k30p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k30p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4025,12 +4213,12 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":880 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":880 */ __pyx_1 = (__pyx_v_fnonc < 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; goto __pyx_L1;} - Py_INCREF(__pyx_k93p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k93p); + Py_INCREF(__pyx_k32p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k32p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4040,7 +4228,7 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":882 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":882 */ __pyx_2 = __pyx_f_6mtrand_cont3_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_fdfnum,__pyx_v_fdfden,__pyx_v_fnonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -4049,35 +4237,35 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":885 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":885 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":887 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":887 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_dfnum,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_odfnum)); __pyx_v_odfnum = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":888 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":888 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_dfden,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_odfden)); __pyx_v_odfden = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":889 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":889 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_nonc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_ononc)); __pyx_v_ononc = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":891 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":891 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} @@ -4099,8 +4287,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} - Py_INCREF(__pyx_k94p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k94p); + Py_INCREF(__pyx_k31p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k31p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4110,11 +4298,11 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":893 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":893 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} @@ -4136,8 +4324,8 @@ Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} - Py_INCREF(__pyx_k95p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k95p); + Py_INCREF(__pyx_k30p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k30p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -4147,11 +4335,11 @@ } __pyx_L7:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":895 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":895 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_less); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} @@ -4173,8 +4361,8 @@ Py_DECREF(__pyx_4); __pyx_4 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;} - Py_INCREF(__pyx_k96p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k96p); + Py_INCREF(__pyx_k32p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k32p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -4184,7 +4372,7 @@ } __pyx_L8:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":897 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":897 */ __pyx_5 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_odfnum,__pyx_v_odfden,__pyx_v_ononc); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; goto __pyx_L1;} __pyx_r = __pyx_5; __pyx_5 = 0; @@ -4211,12 +4399,6 @@ return __pyx_r; } -static PyObject *__pyx_k97p; -static PyObject *__pyx_k98p; - -static char __pyx_k97[] = "df <= 0"; -static char __pyx_k98[] = "df <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_chisquare[] = "Chi^2 distribution.\n\n chisquare(df, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -4231,26 +4413,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"df","size",0}; - __pyx_v_size = __pyx_k26; + __pyx_v_size = __pyx_d25; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_df); Py_INCREF(__pyx_v_size); __pyx_v_odf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":908 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":908 */ __pyx_v_fdf = PyFloat_AsDouble(__pyx_v_df); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":909 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":909 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":910 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":910 */ __pyx_1 = (__pyx_v_fdf <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;} - Py_INCREF(__pyx_k97p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k97p); + Py_INCREF(__pyx_k34p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4260,7 +4442,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":912 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":912 */ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_fdf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -4269,21 +4451,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":914 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":914 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":916 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":916 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_odf)); __pyx_v_odf = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":917 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":917 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} @@ -4305,8 +4487,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;} - Py_INCREF(__pyx_k98p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k98p); + Py_INCREF(__pyx_k34p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4316,7 +4498,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":919 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":919 */ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_odf); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -4339,16 +4521,6 @@ return __pyx_r; } -static PyObject *__pyx_k99p; -static PyObject *__pyx_k100p; -static PyObject *__pyx_k101p; -static PyObject *__pyx_k102p; - -static char __pyx_k99[] = "df <= 0"; -static char __pyx_k100[] = "nonc <= 0"; -static char __pyx_k101[] = "df <= 1"; -static char __pyx_k102[] = "nonc < 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_noncentral_chisquare[] = "Noncentral Chi^2 distribution.\n\n noncentral_chisquare(df, nonc, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -4366,7 +4538,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"df","nonc","size",0}; - __pyx_v_size = __pyx_k27; + __pyx_v_size = __pyx_d26; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_df, &__pyx_v_nonc, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_df); @@ -4375,22 +4547,22 @@ __pyx_v_odf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_ononc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":928 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":928 */ __pyx_v_fdf = PyFloat_AsDouble(__pyx_v_df); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":929 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":929 */ __pyx_v_fnonc = PyFloat_AsDouble(__pyx_v_nonc); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":930 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":930 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":931 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":931 */ __pyx_1 = (__pyx_v_fdf <= 1); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;} - Py_INCREF(__pyx_k99p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k99p); + Py_INCREF(__pyx_k34p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4400,12 +4572,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":933 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":933 */ __pyx_1 = (__pyx_v_fnonc <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;} - Py_INCREF(__pyx_k100p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k100p); + Py_INCREF(__pyx_k35p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k35p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4415,7 +4587,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":935 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":935 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_fdf,__pyx_v_fnonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -4424,28 +4596,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":938 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":938 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":940 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":940 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_odf)); __pyx_v_odf = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":941 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":941 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_nonc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_ononc)); __pyx_v_ononc = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":942 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":942 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} @@ -4467,8 +4639,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;} - Py_INCREF(__pyx_k101p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k101p); + Py_INCREF(__pyx_k36p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k36p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -4478,11 +4650,11 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":944 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":944 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;} @@ -4504,8 +4676,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;} - Py_INCREF(__pyx_k102p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k102p); + Py_INCREF(__pyx_k32p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k32p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -4515,7 +4687,7 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":946 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":946 */ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_odf,__pyx_v_ononc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -4547,7 +4719,7 @@ PyObject *__pyx_r; PyObject *__pyx_1 = 0; static char *__pyx_argnames[] = {"size",0}; - __pyx_v_size = __pyx_k28; + __pyx_v_size = __pyx_d27; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_size); @@ -4568,12 +4740,6 @@ return __pyx_r; } -static PyObject *__pyx_k103p; -static PyObject *__pyx_k104p; - -static char __pyx_k103[] = "df <= 0"; -static char __pyx_k104[] = "df <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_standard_t[] = "Standard Student\'s t distribution with df degrees of freedom.\n\n standard_t(df, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -4588,26 +4754,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"df","size",0}; - __pyx_v_size = __pyx_k29; + __pyx_v_size = __pyx_d28; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_df); Py_INCREF(__pyx_v_size); __pyx_v_odf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":964 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":964 */ __pyx_v_fdf = PyFloat_AsDouble(__pyx_v_df); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":965 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":965 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":966 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":966 */ __pyx_1 = (__pyx_v_fdf <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; goto __pyx_L1;} - Py_INCREF(__pyx_k103p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k103p); + Py_INCREF(__pyx_k34p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4617,7 +4783,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":968 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":968 */ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_fdf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -4626,21 +4792,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":970 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":970 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":972 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":972 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_df,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_odf)); __pyx_v_odf = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":973 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":973 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; goto __pyx_L1;} @@ -4662,8 +4828,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; goto __pyx_L1;} - Py_INCREF(__pyx_k104p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k104p); + Py_INCREF(__pyx_k34p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k34p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4673,7 +4839,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":975 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":975 */ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_odf); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -4696,12 +4862,6 @@ return __pyx_r; } -static PyObject *__pyx_k105p; -static PyObject *__pyx_k106p; - -static char __pyx_k105[] = "kappa < 0"; -static char __pyx_k106[] = "kappa < 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_vonmises[] = "von Mises circular distribution with mode mu and dispersion parameter\n kappa on [-pi, pi].\n\n vonmises(mu, kappa, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -4719,7 +4879,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"mu","kappa","size",0}; - __pyx_v_size = __pyx_k30; + __pyx_v_size = __pyx_d29; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_mu, &__pyx_v_kappa, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_mu); @@ -4728,22 +4888,22 @@ __pyx_v_omu = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_okappa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":986 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":986 */ __pyx_v_fmu = PyFloat_AsDouble(__pyx_v_mu); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":987 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":987 */ __pyx_v_fkappa = PyFloat_AsDouble(__pyx_v_kappa); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":988 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":988 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":989 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":989 */ __pyx_1 = (__pyx_v_fkappa < 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; goto __pyx_L1;} - Py_INCREF(__pyx_k105p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k105p); + Py_INCREF(__pyx_k37p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k37p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4753,7 +4913,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":991 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":991 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_fmu,__pyx_v_fkappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -4762,28 +4922,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":993 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":993 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":995 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":995 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_mu,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_omu)); __pyx_v_omu = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":996 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":996 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_kappa,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_okappa)); __pyx_v_okappa = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":997 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":997 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; goto __pyx_L1;} @@ -4805,8 +4965,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; goto __pyx_L1;} - Py_INCREF(__pyx_k106p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k106p); + Py_INCREF(__pyx_k37p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k37p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -4816,7 +4976,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":999 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":999 */ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_omu,__pyx_v_okappa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -4841,12 +5001,6 @@ return __pyx_r; } -static PyObject *__pyx_k107p; -static PyObject *__pyx_k108p; - -static char __pyx_k107[] = "a <= 0"; -static char __pyx_k108[] = "a <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_pareto[] = "Pareto distribution.\n\n pareto(a, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -4861,26 +5015,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"a","size",0}; - __pyx_v_size = __pyx_k31; + __pyx_v_size = __pyx_d30; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_a); Py_INCREF(__pyx_v_size); __pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1009 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1009 */ __pyx_v_fa = PyFloat_AsDouble(__pyx_v_a); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1010 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1010 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1011 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1011 */ __pyx_1 = (__pyx_v_fa <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; goto __pyx_L1;} - Py_INCREF(__pyx_k107p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k107p); + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4890,7 +5044,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1013 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1013 */ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -4899,21 +5053,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1015 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1015 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1017 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1017 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oa)); __pyx_v_oa = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1018 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1018 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; goto __pyx_L1;} @@ -4935,8 +5089,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; goto __pyx_L1;} - Py_INCREF(__pyx_k108p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k108p); + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -4946,7 +5100,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1020 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1020 */ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -4969,12 +5123,6 @@ return __pyx_r; } -static PyObject *__pyx_k109p; -static PyObject *__pyx_k110p; - -static char __pyx_k109[] = "a <= 0"; -static char __pyx_k110[] = "a <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_weibull[] = "Weibull distribution.\n\n weibull(a, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -4989,26 +5137,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"a","size",0}; - __pyx_v_size = __pyx_k32; + __pyx_v_size = __pyx_d31; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_a); Py_INCREF(__pyx_v_size); __pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1030 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1030 */ __pyx_v_fa = PyFloat_AsDouble(__pyx_v_a); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1031 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1031 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1032 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1032 */ __pyx_1 = (__pyx_v_fa <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; goto __pyx_L1;} - Py_INCREF(__pyx_k109p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k109p); + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5018,7 +5166,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1034 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1034 */ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -5027,21 +5175,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1036 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1036 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1038 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1038 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oa)); __pyx_v_oa = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1039 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1039 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; goto __pyx_L1;} @@ -5063,8 +5211,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; goto __pyx_L1;} - Py_INCREF(__pyx_k110p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k110p); + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5074,7 +5222,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1041 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1041 */ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -5097,12 +5245,6 @@ return __pyx_r; } -static PyObject *__pyx_k111p; -static PyObject *__pyx_k112p; - -static char __pyx_k111[] = "a <= 0"; -static char __pyx_k112[] = "a <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_power[] = "Power distribution.\n\n power(a, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -5117,26 +5259,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"a","size",0}; - __pyx_v_size = __pyx_k33; + __pyx_v_size = __pyx_d32; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_a); Py_INCREF(__pyx_v_size); __pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1051 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1051 */ __pyx_v_fa = PyFloat_AsDouble(__pyx_v_a); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1052 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1052 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1053 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1053 */ __pyx_1 = (__pyx_v_fa <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; goto __pyx_L1;} - Py_INCREF(__pyx_k111p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k111p); + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5146,7 +5288,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1055 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1055 */ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -5155,21 +5297,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1057 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1057 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1059 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1059 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oa)); __pyx_v_oa = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1060 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1060 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; goto __pyx_L1;} @@ -5191,8 +5333,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; goto __pyx_L1;} - Py_INCREF(__pyx_k112p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k112p); + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5202,7 +5344,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1062 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1062 */ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -5225,12 +5367,6 @@ return __pyx_r; } -static PyObject *__pyx_k113p; -static PyObject *__pyx_k114p; - -static char __pyx_k113[] = "scale <= 0"; -static char __pyx_k114[] = "scale <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_laplace[] = "Laplace distribution.\n\n laplace(loc=0.0, scale=1.0, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -5248,9 +5384,9 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"loc","scale","size",0}; - __pyx_v_loc = __pyx_k34; - __pyx_v_scale = __pyx_k35; - __pyx_v_size = __pyx_k36; + __pyx_v_loc = __pyx_d33; + __pyx_v_scale = __pyx_d34; + __pyx_v_size = __pyx_d35; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_loc); @@ -5259,22 +5395,22 @@ __pyx_v_oloc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1072 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1072 */ __pyx_v_floc = PyFloat_AsDouble(__pyx_v_loc); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1073 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1073 */ __pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1074 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1074 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1075 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1075 */ __pyx_1 = (__pyx_v_fscale <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; goto __pyx_L1;} - Py_INCREF(__pyx_k113p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k113p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5284,7 +5420,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1077 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1077 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1077; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -5293,28 +5429,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1079 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1079 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1080 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1080 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_oloc)); __pyx_v_oloc = ((PyArrayObject *)__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1081 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1081 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_oscale)); __pyx_v_oscale = ((PyArrayObject *)__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1082 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1082 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; goto __pyx_L1;} @@ -5336,8 +5472,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; goto __pyx_L1;} - Py_INCREF(__pyx_k114p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k114p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k23p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -5347,7 +5483,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1084 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1084 */ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -5372,12 +5508,6 @@ return __pyx_r; } -static PyObject *__pyx_k115p; -static PyObject *__pyx_k116p; - -static char __pyx_k115[] = "scale <= 0"; -static char __pyx_k116[] = "scale <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_gumbel[] = "Gumbel distribution.\n\n gumbel(loc=0.0, scale=1.0, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -5395,9 +5525,9 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"loc","scale","size",0}; - __pyx_v_loc = __pyx_k37; - __pyx_v_scale = __pyx_k38; - __pyx_v_size = __pyx_k39; + __pyx_v_loc = __pyx_d36; + __pyx_v_scale = __pyx_d37; + __pyx_v_size = __pyx_d38; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_loc); @@ -5406,22 +5536,22 @@ __pyx_v_oloc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1094 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1094 */ __pyx_v_floc = PyFloat_AsDouble(__pyx_v_loc); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1095 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1095 */ __pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1096 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1096 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1097 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1097 */ __pyx_1 = (__pyx_v_fscale <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; goto __pyx_L1;} - Py_INCREF(__pyx_k115p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k115p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5431,7 +5561,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1099 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1099 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -5440,28 +5570,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1101 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1101 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1102 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1102 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_oloc)); __pyx_v_oloc = ((PyArrayObject *)__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1103 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1103 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_oscale)); __pyx_v_oscale = ((PyArrayObject *)__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1104 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1104 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; goto __pyx_L1;} @@ -5483,8 +5613,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;} - Py_INCREF(__pyx_k116p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k116p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k23p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -5494,7 +5624,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1106 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1106 */ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -5519,12 +5649,6 @@ return __pyx_r; } -static PyObject *__pyx_k117p; -static PyObject *__pyx_k118p; - -static char __pyx_k117[] = "scale <= 0"; -static char __pyx_k118[] = "scale <= 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_logistic[] = "Logistic distribution.\n\n logistic(loc=0.0, scale=1.0, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -5542,9 +5666,9 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"loc","scale","size",0}; - __pyx_v_loc = __pyx_k40; - __pyx_v_scale = __pyx_k41; - __pyx_v_size = __pyx_k42; + __pyx_v_loc = __pyx_d39; + __pyx_v_scale = __pyx_d40; + __pyx_v_size = __pyx_d41; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_loc); @@ -5553,22 +5677,22 @@ __pyx_v_oloc = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1116 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1116 */ __pyx_v_floc = PyFloat_AsDouble(__pyx_v_loc); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1117 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1117 */ __pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1118 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1118 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1119 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1119 */ __pyx_1 = (__pyx_v_fscale <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; goto __pyx_L1;} - Py_INCREF(__pyx_k117p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k117p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5578,7 +5702,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1121 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1121 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_floc,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -5587,28 +5711,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1123 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1123 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1124 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1124 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_loc,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_oloc)); __pyx_v_oloc = ((PyArrayObject *)__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1125 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1125 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_oscale)); __pyx_v_oscale = ((PyArrayObject *)__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1126 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1126 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; goto __pyx_L1;} @@ -5630,8 +5754,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; goto __pyx_L1;} - Py_INCREF(__pyx_k118p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k118p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k23p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -5641,7 +5765,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1128 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1128 */ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_oloc,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -5666,12 +5790,6 @@ return __pyx_r; } -static PyObject *__pyx_k119p; -static PyObject *__pyx_k120p; - -static char __pyx_k119[] = "sigma <= 0"; -static char __pyx_k120[] = "sigma <= 0.0"; - static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_lognormal[] = "Log-normal distribution.\n\n Note that the mean parameter is not the mean of this distribution, but\n the underlying normal distribution.\n\n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\n\n lognormal(mean=0.0, sigma=1.0, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -5689,9 +5807,9 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"mean","sigma","size",0}; - __pyx_v_mean = __pyx_k43; - __pyx_v_sigma = __pyx_k44; - __pyx_v_size = __pyx_k45; + __pyx_v_mean = __pyx_d42; + __pyx_v_sigma = __pyx_d43; + __pyx_v_size = __pyx_d44; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_mean, &__pyx_v_sigma, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_mean); @@ -5700,22 +5818,22 @@ __pyx_v_omean = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_osigma = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1143 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1143 */ __pyx_v_fmean = PyFloat_AsDouble(__pyx_v_mean); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1144 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1144 */ __pyx_v_fsigma = PyFloat_AsDouble(__pyx_v_sigma); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1146 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1146 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1147 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1147 */ __pyx_1 = (__pyx_v_fsigma <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; goto __pyx_L1;} - Py_INCREF(__pyx_k119p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k119p); + Py_INCREF(__pyx_k38p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k38p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5725,7 +5843,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1149 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1149 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_fmean,__pyx_v_fsigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -5734,28 +5852,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1151 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1151 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1153 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1153 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_mean,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_omean)); __pyx_v_omean = ((PyArrayObject *)__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1154 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1154 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_sigma,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_osigma)); __pyx_v_osigma = ((PyArrayObject *)__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1155 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1155 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; goto __pyx_L1;} @@ -5777,8 +5895,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1156; goto __pyx_L1;} - Py_INCREF(__pyx_k120p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k120p); + Py_INCREF(__pyx_k39p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k39p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1156; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -5788,7 +5906,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1157 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1157 */ __pyx_4 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_omean,__pyx_v_osigma); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1157; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -5813,12 +5931,6 @@ return __pyx_r; } -static PyObject *__pyx_k121p; -static PyObject *__pyx_k122p; - -static char __pyx_k121[] = "scale <= 0"; -static char __pyx_k122[] = "scale <= 0.0"; - static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_rayleigh[] = "Rayleigh distribution.\n\n rayleigh(scale=1.0, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -5833,27 +5945,27 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"scale","size",0}; - __pyx_v_scale = __pyx_k46; - __pyx_v_size = __pyx_k47; + __pyx_v_scale = __pyx_d45; + __pyx_v_size = __pyx_d46; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_scale); Py_INCREF(__pyx_v_size); __pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1167 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1167 */ __pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1169 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1169 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1170 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1170 */ __pyx_1 = (__pyx_v_fscale <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; goto __pyx_L1;} - Py_INCREF(__pyx_k121p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k121p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5863,7 +5975,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1172 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1172 */ __pyx_2 = __pyx_f_6mtrand_cont1_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -5872,21 +5984,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1174 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1174 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1176 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1176 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oscale)); __pyx_v_oscale = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1177 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1177 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; goto __pyx_L1;} @@ -5908,8 +6020,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; goto __pyx_L1;} - Py_INCREF(__pyx_k122p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k122p); + Py_INCREF(__pyx_k40p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k40p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -5919,7 +6031,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1179 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1179 */ __pyx_4 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_oscale); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -5942,16 +6054,6 @@ return __pyx_r; } -static PyObject *__pyx_k123p; -static PyObject *__pyx_k124p; -static PyObject *__pyx_k125p; -static PyObject *__pyx_k126p; - -static char __pyx_k123[] = "mean <= 0"; -static char __pyx_k124[] = "scale <= 0"; -static char __pyx_k125[] = "mean <= 0.0"; -static char __pyx_k126[] = "scale <= 0.0"; - static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_wald[] = "Wald (inverse Gaussian) distribution.\n\n wald(mean, scale, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -5969,7 +6071,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"mean","scale","size",0}; - __pyx_v_size = __pyx_k48; + __pyx_v_size = __pyx_d47; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_mean, &__pyx_v_scale, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_mean); @@ -5978,22 +6080,22 @@ __pyx_v_omean = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_oscale = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1189 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1189 */ __pyx_v_fmean = PyFloat_AsDouble(__pyx_v_mean); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1190 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1190 */ __pyx_v_fscale = PyFloat_AsDouble(__pyx_v_scale); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1191 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1191 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1192 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1192 */ __pyx_1 = (__pyx_v_fmean <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; goto __pyx_L1;} - Py_INCREF(__pyx_k123p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k123p); + Py_INCREF(__pyx_k41p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k41p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6003,12 +6105,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1194 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1194 */ __pyx_1 = (__pyx_v_fscale <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;} - Py_INCREF(__pyx_k124p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k124p); + Py_INCREF(__pyx_k23p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k23p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6018,7 +6120,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1196 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1196 */ __pyx_2 = __pyx_f_6mtrand_cont2_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_fmean,__pyx_v_fscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -6027,28 +6129,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1198 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1198 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1199 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1199 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_mean,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_omean)); __pyx_v_omean = ((PyArrayObject *)__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1200 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1200 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_scale,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6mtrand_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_oscale)); __pyx_v_oscale = ((PyArrayObject *)__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1201 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1201 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; goto __pyx_L1;} @@ -6070,8 +6172,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; goto __pyx_L1;} - Py_INCREF(__pyx_k125p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k125p); + Py_INCREF(__pyx_k42p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k42p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -6079,10 +6181,10 @@ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; goto __pyx_L1;} goto __pyx_L5; } - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; goto __pyx_L1;} @@ -6104,8 +6206,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; goto __pyx_L1;} - Py_INCREF(__pyx_k126p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k126p); + Py_INCREF(__pyx_k40p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k40p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -6115,7 +6217,7 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1205 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1205 */ __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_omean,__pyx_v_oscale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -6140,23 +6242,6 @@ return __pyx_r; } -static PyObject *__pyx_n_greater; -static PyObject *__pyx_n_equal; - -static PyObject *__pyx_k127p; -static PyObject *__pyx_k128p; -static PyObject *__pyx_k129p; -static PyObject *__pyx_k130p; -static PyObject *__pyx_k131p; -static PyObject *__pyx_k132p; - -static char __pyx_k127[] = "left > mode"; -static char __pyx_k128[] = "mode > right"; -static char __pyx_k129[] = "left == right"; -static char __pyx_k130[] = "left > mode"; -static char __pyx_k131[] = "mode > right"; -static char __pyx_k132[] = "left == right"; - static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_triangular[] = "Triangular distribution starting at left, peaking at mode, and\n ending at right (left <= mode <= right).\n\n triangular(left, mode, right, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -6177,7 +6262,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"left","mode","right","size",0}; - __pyx_v_size = __pyx_k49; + __pyx_v_size = __pyx_d48; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO|O", __pyx_argnames, &__pyx_v_left, &__pyx_v_mode, &__pyx_v_right, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_left); @@ -6188,25 +6273,25 @@ __pyx_v_omode = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_oright = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1218 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1218 */ __pyx_v_fleft = PyFloat_AsDouble(__pyx_v_left); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1219 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1219 */ __pyx_v_fright = PyFloat_AsDouble(__pyx_v_right); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1220 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1220 */ __pyx_v_fmode = PyFloat_AsDouble(__pyx_v_mode); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1221 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1221 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1222 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1222 */ __pyx_1 = (__pyx_v_fleft > __pyx_v_fmode); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; goto __pyx_L1;} - Py_INCREF(__pyx_k127p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k127p); + Py_INCREF(__pyx_k43p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k43p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6216,12 +6301,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1224 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1224 */ __pyx_1 = (__pyx_v_fmode > __pyx_v_fright); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; goto __pyx_L1;} - Py_INCREF(__pyx_k128p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k128p); + Py_INCREF(__pyx_k44p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k44p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6231,12 +6316,12 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1226 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1226 */ __pyx_1 = (__pyx_v_fleft == __pyx_v_fright); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; goto __pyx_L1;} - Py_INCREF(__pyx_k129p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k129p); + Py_INCREF(__pyx_k45p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k45p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6246,7 +6331,7 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1228 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1228 */ __pyx_2 = __pyx_f_6mtrand_cont3_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_fleft,__pyx_v_fmode,__pyx_v_fright); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -6255,35 +6340,35 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1231 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1231 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1232 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1232 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_left,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1232; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oleft)); __pyx_v_oleft = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1233 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1233 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_mode,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_omode)); __pyx_v_omode = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1234 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1234 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_right,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oright)); __pyx_v_oright = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1236 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1236 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; goto __pyx_L1;} @@ -6304,8 +6389,8 @@ Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_1) { __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; goto __pyx_L1;} - Py_INCREF(__pyx_k130p); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k130p); + Py_INCREF(__pyx_k43p); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k43p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6315,11 +6400,11 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1238 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1238 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1238; goto __pyx_L1;} @@ -6340,8 +6425,8 @@ Py_DECREF(__pyx_4); __pyx_4 = 0; if (__pyx_1) { __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; goto __pyx_L1;} - Py_INCREF(__pyx_k131p); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k131p); + Py_INCREF(__pyx_k44p); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k44p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -6351,11 +6436,11 @@ } __pyx_L7:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1240 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1240 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_equal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; goto __pyx_L1;} @@ -6376,8 +6461,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; goto __pyx_L1;} - Py_INCREF(__pyx_k132p); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k132p); + Py_INCREF(__pyx_k45p); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k45p); __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __Pyx_Raise(__pyx_4, 0, 0); @@ -6387,7 +6472,7 @@ } __pyx_L8:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1242 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1242 */ __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_oleft,__pyx_v_omode,__pyx_v_oright); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1242; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -6414,20 +6499,6 @@ return __pyx_r; } -static PyObject *__pyx_k133p; -static PyObject *__pyx_k134p; -static PyObject *__pyx_k135p; -static PyObject *__pyx_k136p; -static PyObject *__pyx_k137p; -static PyObject *__pyx_k138p; - -static char __pyx_k133[] = "n <= 0"; -static char __pyx_k134[] = "p < 0"; -static char __pyx_k135[] = "p > 1"; -static char __pyx_k136[] = "n <= 0"; -static char __pyx_k137[] = "p < 0"; -static char __pyx_k138[] = "p > 1"; - static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_binomial[] = "Binomial distribution of n trials and p probability of success.\n\n binomial(n, p, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -6445,7 +6516,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"n","p","size",0}; - __pyx_v_size = __pyx_k50; + __pyx_v_size = __pyx_d49; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_n); @@ -6454,22 +6525,22 @@ __pyx_v_on = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_op = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1255 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1255 */ __pyx_v_fp = PyFloat_AsDouble(__pyx_v_p); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1256 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1256 */ __pyx_v_ln = PyInt_AsLong(__pyx_v_n); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1257 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1257 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1258 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1258 */ __pyx_1 = (__pyx_v_ln <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1259; goto __pyx_L1;} - Py_INCREF(__pyx_k133p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k133p); + Py_INCREF(__pyx_k48p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k48p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1259; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6479,12 +6550,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1260 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1260 */ __pyx_1 = (__pyx_v_fp < 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1261; goto __pyx_L1;} - Py_INCREF(__pyx_k134p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k134p); + Py_INCREF(__pyx_k49p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k49p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1261; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6495,8 +6566,8 @@ __pyx_1 = (__pyx_v_fp > 1); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; goto __pyx_L1;} - Py_INCREF(__pyx_k135p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k135p); + Py_INCREF(__pyx_k50p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k50p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6506,7 +6577,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1264 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1264 */ __pyx_2 = __pyx_f_6mtrand_discnp_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_ln,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -6515,28 +6586,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1266 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1266 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1268 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1268 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_n,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_on)); __pyx_v_on = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1269 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1269 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_op)); __pyx_v_op = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1270 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1270 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; goto __pyx_L1;} @@ -6558,8 +6629,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1271; goto __pyx_L1;} - Py_INCREF(__pyx_k136p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k136p); + Py_INCREF(__pyx_k48p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k48p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1271; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -6569,11 +6640,11 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1272 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1272 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; goto __pyx_L1;} @@ -6595,8 +6666,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; goto __pyx_L1;} - Py_INCREF(__pyx_k137p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k137p); + Py_INCREF(__pyx_k49p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k49p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -6606,11 +6677,11 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1274 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1274 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_greater); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; goto __pyx_L1;} @@ -6632,8 +6703,8 @@ Py_DECREF(__pyx_4); __pyx_4 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; goto __pyx_L1;} - Py_INCREF(__pyx_k138p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k138p); + Py_INCREF(__pyx_k50p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k50p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6643,7 +6714,7 @@ } __pyx_L7:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1276 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1276 */ __pyx_5 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_on,__pyx_v_op); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1276; goto __pyx_L1;} __pyx_r = __pyx_5; __pyx_5 = 0; @@ -6668,20 +6739,6 @@ return __pyx_r; } -static PyObject *__pyx_k139p; -static PyObject *__pyx_k140p; -static PyObject *__pyx_k141p; -static PyObject *__pyx_k142p; -static PyObject *__pyx_k143p; -static PyObject *__pyx_k144p; - -static char __pyx_k139[] = "n <= 0"; -static char __pyx_k140[] = "p < 0"; -static char __pyx_k141[] = "p > 1"; -static char __pyx_k142[] = "n <= 0"; -static char __pyx_k143[] = "p < 0"; -static char __pyx_k144[] = "p > 1"; - static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = "Negative Binomial distribution.\n\n negative_binomial(n, p, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -6699,7 +6756,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"n","p","size",0}; - __pyx_v_size = __pyx_k51; + __pyx_v_size = __pyx_d50; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_n); @@ -6708,22 +6765,22 @@ __pyx_v_on = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_op = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1288 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1288 */ __pyx_v_fp = PyFloat_AsDouble(__pyx_v_p); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1289 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1289 */ __pyx_v_ln = PyInt_AsLong(__pyx_v_n); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1290 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1290 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1291 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1291 */ __pyx_1 = (__pyx_v_ln <= 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; goto __pyx_L1;} - Py_INCREF(__pyx_k139p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k139p); + Py_INCREF(__pyx_k48p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k48p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6733,12 +6790,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1293 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1293 */ __pyx_1 = (__pyx_v_fp < 0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; goto __pyx_L1;} - Py_INCREF(__pyx_k140p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k140p); + Py_INCREF(__pyx_k49p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k49p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6749,8 +6806,8 @@ __pyx_1 = (__pyx_v_fp > 1); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; goto __pyx_L1;} - Py_INCREF(__pyx_k141p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k141p); + Py_INCREF(__pyx_k50p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k50p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6760,7 +6817,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1297 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1297 */ __pyx_2 = __pyx_f_6mtrand_discnp_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_ln,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -6769,28 +6826,28 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1300 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1300 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1302 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1302 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_n,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1302; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_on)); __pyx_v_on = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1303 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1303 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1303; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_op)); __pyx_v_op = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1304 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1304 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; goto __pyx_L1;} @@ -6812,8 +6869,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; goto __pyx_L1;} - Py_INCREF(__pyx_k142p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k142p); + Py_INCREF(__pyx_k48p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k48p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -6823,11 +6880,11 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1306 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1306 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; goto __pyx_L1;} @@ -6849,8 +6906,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; goto __pyx_L1;} - Py_INCREF(__pyx_k143p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k143p); + Py_INCREF(__pyx_k49p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k49p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -6860,11 +6917,11 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1308 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1308 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_greater); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; goto __pyx_L1;} @@ -6886,8 +6943,8 @@ Py_DECREF(__pyx_4); __pyx_4 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; goto __pyx_L1;} - Py_INCREF(__pyx_k144p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k144p); + Py_INCREF(__pyx_k50p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k50p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6897,7 +6954,7 @@ } __pyx_L7:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1310 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1310 */ __pyx_5 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_on,__pyx_v_op); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; goto __pyx_L1;} __pyx_r = __pyx_5; __pyx_5 = 0; @@ -6922,12 +6979,6 @@ return __pyx_r; } -static PyObject *__pyx_k145p; -static PyObject *__pyx_k146p; - -static char __pyx_k145[] = "lam < 0"; -static char __pyx_k146[] = "lam < 0"; - static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_poisson[] = "Poisson distribution.\n\n poisson(lam=1.0, size=None) -> random values\n "; static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -6942,30 +6993,30 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"lam","size",0}; - __pyx_v_lam = __pyx_k52; - __pyx_v_size = __pyx_k53; + __pyx_v_lam = __pyx_d51; + __pyx_v_size = __pyx_d52; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_lam, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_lam); Py_INCREF(__pyx_v_size); __pyx_v_olam = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1320 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1320 */ __pyx_v_flam = PyFloat_AsDouble(__pyx_v_lam); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1321 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1321 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1322 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1322 */ __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; goto __pyx_L1;} if (PyObject_Cmp(__pyx_v_lam, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; goto __pyx_L1;} __pyx_1 = __pyx_1 < 0; Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; goto __pyx_L1;} - Py_INCREF(__pyx_k145p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k145p); + Py_INCREF(__pyx_k51p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k51p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -6975,7 +7026,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1324 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1324 */ __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_flam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -6984,21 +7035,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1326 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1326 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1328 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1328 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_lam,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1328; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_olam)); __pyx_v_olam = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1329 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1329 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; goto __pyx_L1;} @@ -7020,8 +7071,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; goto __pyx_L1;} - Py_INCREF(__pyx_k146p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k146p); + Py_INCREF(__pyx_k51p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k51p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7031,7 +7082,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1331 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1331 */ __pyx_4 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_olam); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -7054,12 +7105,6 @@ return __pyx_r; } -static PyObject *__pyx_k147p; -static PyObject *__pyx_k148p; - -static char __pyx_k147[] = "a <= 1.0"; -static char __pyx_k148[] = "a <= 1.0"; - static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_zipf[] = "Zipf distribution.\n\n zipf(a, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -7074,26 +7119,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"a","size",0}; - __pyx_v_size = __pyx_k54; + __pyx_v_size = __pyx_d53; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_a); Py_INCREF(__pyx_v_size); __pyx_v_oa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1341 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1341 */ __pyx_v_fa = PyFloat_AsDouble(__pyx_v_a); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1342 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1342 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1343 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1343 */ __pyx_1 = (__pyx_v_fa <= 1.0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; goto __pyx_L1;} - Py_INCREF(__pyx_k147p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k147p); + Py_INCREF(__pyx_k52p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k52p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7103,7 +7148,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1345 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1345 */ __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_fa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -7112,21 +7157,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1347 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1347 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1349 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1349 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_a,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1349; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_oa)); __pyx_v_oa = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1350 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1350 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less_equal); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; goto __pyx_L1;} @@ -7148,8 +7193,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; goto __pyx_L1;} - Py_INCREF(__pyx_k148p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k148p); + Py_INCREF(__pyx_k52p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k52p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7159,7 +7204,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1352 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1352 */ __pyx_4 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_oa); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1352; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -7182,16 +7227,6 @@ return __pyx_r; } -static PyObject *__pyx_k149p; -static PyObject *__pyx_k150p; -static PyObject *__pyx_k151p; -static PyObject *__pyx_k152p; - -static char __pyx_k149[] = "p < 0.0"; -static char __pyx_k150[] = "p > 1.0"; -static char __pyx_k151[] = "p < 0.0"; -static char __pyx_k152[] = "p > 1.0"; - static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_geometric[] = "Geometric distribution with p being the probability of \"success\" on\n an individual trial.\n\n geometric(p, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -7206,26 +7241,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"p","size",0}; - __pyx_v_size = __pyx_k55; + __pyx_v_size = __pyx_d54; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_p); Py_INCREF(__pyx_v_size); __pyx_v_op = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1363 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1363 */ __pyx_v_fp = PyFloat_AsDouble(__pyx_v_p); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1364 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1364 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1365 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1365 */ __pyx_1 = (__pyx_v_fp < 0.0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; goto __pyx_L1;} - Py_INCREF(__pyx_k149p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k149p); + Py_INCREF(__pyx_k53p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k53p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7235,12 +7270,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1367 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1367 */ __pyx_1 = (__pyx_v_fp > 1.0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; goto __pyx_L1;} - Py_INCREF(__pyx_k150p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k150p); + Py_INCREF(__pyx_k54p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k54p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7250,7 +7285,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1369 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1369 */ __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -7259,21 +7294,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1371 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1371 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1374 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1374 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1374; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_op)); __pyx_v_op = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1375 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1375 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; goto __pyx_L1;} @@ -7295,8 +7330,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; goto __pyx_L1;} - Py_INCREF(__pyx_k151p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k151p); + Py_INCREF(__pyx_k53p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k53p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7306,11 +7341,11 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1377 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1377 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; goto __pyx_L1;} @@ -7332,8 +7367,8 @@ Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; goto __pyx_L1;} - Py_INCREF(__pyx_k152p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k152p); + Py_INCREF(__pyx_k54p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k54p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -7343,7 +7378,7 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1379 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1379 */ __pyx_3 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_op); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1379; goto __pyx_L1;} __pyx_r = __pyx_3; __pyx_3 = 0; @@ -7366,26 +7401,6 @@ return __pyx_r; } -static PyObject *__pyx_n_add; - -static PyObject *__pyx_k153p; -static PyObject *__pyx_k154p; -static PyObject *__pyx_k155p; -static PyObject *__pyx_k156p; -static PyObject *__pyx_k157p; -static PyObject *__pyx_k158p; -static PyObject *__pyx_k159p; -static PyObject *__pyx_k160p; - -static char __pyx_k153[] = "ngood < 1"; -static char __pyx_k154[] = "nbad < 1"; -static char __pyx_k155[] = "nsample < 1"; -static char __pyx_k156[] = "ngood + nbad < nsample"; -static char __pyx_k157[] = "ngood < 1"; -static char __pyx_k158[] = "nbad < 1"; -static char __pyx_k159[] = "nsample < 1"; -static char __pyx_k160[] = "ngood + nbad < nsample"; - static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_hypergeometric[] = "Hypergeometric distribution.\n\n Consider an urn with ngood \"good\" balls and nbad \"bad\" balls. If one\n were to draw nsample balls from the urn without replacement, then\n the hypergeometric distribution describes the distribution of \"good\"\n balls in the sample.\n\n hypergeometric(ngood, nbad, nsample, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -7407,7 +7422,7 @@ PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; static char *__pyx_argnames[] = {"ngood","nbad","nsample","size",0}; - __pyx_v_size = __pyx_k56; + __pyx_v_size = __pyx_d55; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO|O", __pyx_argnames, &__pyx_v_ngood, &__pyx_v_nbad, &__pyx_v_nsample, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_ngood); @@ -7418,28 +7433,28 @@ __pyx_v_onbad = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_onsample = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1394 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1394 */ __pyx_v_lngood = PyInt_AsLong(__pyx_v_ngood); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1395 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1395 */ __pyx_v_lnbad = PyInt_AsLong(__pyx_v_nbad); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1396 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1396 */ __pyx_v_lnsample = PyInt_AsLong(__pyx_v_nsample); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1397 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1397 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1398 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1398 */ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; goto __pyx_L1;} if (PyObject_Cmp(__pyx_v_ngood, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; goto __pyx_L1;} __pyx_1 = __pyx_1 < 0; Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1399; goto __pyx_L1;} - Py_INCREF(__pyx_k153p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k153p); + Py_INCREF(__pyx_k55p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k55p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1399; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7449,15 +7464,15 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1400 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1400 */ __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; goto __pyx_L1;} if (PyObject_Cmp(__pyx_v_nbad, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; goto __pyx_L1;} __pyx_1 = __pyx_1 < 0; Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; goto __pyx_L1;} - Py_INCREF(__pyx_k154p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k154p); + Py_INCREF(__pyx_k56p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k56p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -7467,15 +7482,15 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1402 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1402 */ __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; goto __pyx_L1;} if (PyObject_Cmp(__pyx_v_nsample, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; goto __pyx_L1;} __pyx_1 = __pyx_1 < 0; Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; goto __pyx_L1;} - Py_INCREF(__pyx_k155p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k155p); + Py_INCREF(__pyx_k57p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k57p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7485,15 +7500,15 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1404 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1404 */ __pyx_2 = PyNumber_Add(__pyx_v_ngood, __pyx_v_nbad); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1404; goto __pyx_L1;} if (PyObject_Cmp(__pyx_2, __pyx_v_nsample, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1404; goto __pyx_L1;} __pyx_1 = __pyx_1 < 0; Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; goto __pyx_L1;} - Py_INCREF(__pyx_k156p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k156p); + Py_INCREF(__pyx_k58p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k58p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -7503,7 +7518,7 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1406 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1406 */ __pyx_3 = __pyx_f_6mtrand_discnmN_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_lngood,__pyx_v_lnbad,__pyx_v_lnsample); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1406; goto __pyx_L1;} __pyx_r = __pyx_3; __pyx_3 = 0; @@ -7512,35 +7527,35 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1410 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1410 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1412 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1412 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_ngood,NPY_LONG,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_ongood)); __pyx_v_ongood = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1413 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1413 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_nbad,NPY_LONG,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_onbad)); __pyx_v_onbad = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1414 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1414 */ __pyx_2 = PyArray_FROM_OTF(__pyx_v_nsample,NPY_LONG,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_onsample)); __pyx_v_onsample = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1415 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1415 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_any); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; goto __pyx_L1;} @@ -7562,8 +7577,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; goto __pyx_L1;} - Py_INCREF(__pyx_k157p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k157p); + Py_INCREF(__pyx_k55p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k55p); __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_2, 0, 0); @@ -7573,11 +7588,11 @@ } __pyx_L7:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1417 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1417 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_less); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; goto __pyx_L1;} @@ -7599,8 +7614,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; goto __pyx_L1;} - Py_INCREF(__pyx_k158p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k158p); + Py_INCREF(__pyx_k56p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k56p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -7610,11 +7625,11 @@ } __pyx_L8:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1419 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1419 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_less); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; goto __pyx_L1;} @@ -7636,8 +7651,8 @@ Py_DECREF(__pyx_4); __pyx_4 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; goto __pyx_L1;} - Py_INCREF(__pyx_k159p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k159p); + Py_INCREF(__pyx_k57p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k57p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7647,14 +7662,14 @@ } __pyx_L9:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1421 */ - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1421 */ + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_n_any); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_add); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; goto __pyx_L1;} @@ -7683,8 +7698,8 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; goto __pyx_L1;} - Py_INCREF(__pyx_k160p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k160p); + Py_INCREF(__pyx_k58p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k58p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -7694,7 +7709,7 @@ } __pyx_L10:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1423 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1423 */ __pyx_4 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ongood,__pyx_v_onbad,__pyx_v_onsample); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; goto __pyx_L1;} __pyx_r = __pyx_4; __pyx_4 = 0; @@ -7722,16 +7737,6 @@ return __pyx_r; } -static PyObject *__pyx_k161p; -static PyObject *__pyx_k162p; -static PyObject *__pyx_k163p; -static PyObject *__pyx_k164p; - -static char __pyx_k161[] = "p < 0.0"; -static char __pyx_k162[] = "p > 1.0"; -static char __pyx_k163[] = "p < 0.0"; -static char __pyx_k164[] = "p > 1.0"; - static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_logseries[] = "Logarithmic series distribution.\n\n logseries(p, size=None)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -7746,26 +7751,26 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"p","size",0}; - __pyx_v_size = __pyx_k57; + __pyx_v_size = __pyx_d56; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_p); Py_INCREF(__pyx_v_size); __pyx_v_op = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1434 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1434 */ __pyx_v_fp = PyFloat_AsDouble(__pyx_v_p); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1435 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1435 */ __pyx_1 = (!PyErr_Occurred()); if (__pyx_1) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1436 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1436 */ __pyx_1 = (__pyx_v_fp < 0.0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; goto __pyx_L1;} - Py_INCREF(__pyx_k161p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k161p); + Py_INCREF(__pyx_k53p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k53p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7775,12 +7780,12 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1438 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1438 */ __pyx_1 = (__pyx_v_fp > 1.0); if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; goto __pyx_L1;} - Py_INCREF(__pyx_k162p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k162p); + Py_INCREF(__pyx_k54p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k54p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7790,7 +7795,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1440 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1440 */ __pyx_2 = __pyx_f_6mtrand_discd_array_sc(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_fp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; goto __pyx_L1;} __pyx_r = __pyx_2; __pyx_2 = 0; @@ -7799,21 +7804,21 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1442 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1442 */ PyErr_Clear(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1444 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1444 */ __pyx_3 = PyArray_FROM_OTF(__pyx_v_p,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(__pyx_3); Py_DECREF(((PyObject *)__pyx_v_op)); __pyx_v_op = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1445 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1445 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;} __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_less); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; goto __pyx_L1;} @@ -7835,8 +7840,8 @@ Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; goto __pyx_L1;} - Py_INCREF(__pyx_k163p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k163p); + Py_INCREF(__pyx_k53p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k53p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -7846,11 +7851,11 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1447 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1447 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_any); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_greater); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1447; goto __pyx_L1;} @@ -7872,8 +7877,8 @@ Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_1) { __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; goto __pyx_L1;} - Py_INCREF(__pyx_k164p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k164p); + Py_INCREF(__pyx_k54p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k54p); __pyx_5 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); @@ -7883,7 +7888,7 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1449 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1449 */ __pyx_3 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_op); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; goto __pyx_L1;} __pyx_r = __pyx_3; __pyx_3 = 0; @@ -7906,25 +7911,6 @@ return __pyx_r; } -static PyObject *__pyx_n_array; -static PyObject *__pyx_n_shape; -static PyObject *__pyx_n_append; -static PyObject *__pyx_n_multiply; -static PyObject *__pyx_n_reduce; -static PyObject *__pyx_n_svd; -static PyObject *__pyx_n_dot; -static PyObject *__pyx_n_sqrt; - -static PyObject *__pyx_k165p; -static PyObject *__pyx_k166p; -static PyObject *__pyx_k167p; -static PyObject *__pyx_k168p; - -static char __pyx_k165[] = "mean must be 1 dimensional"; -static char __pyx_k166[] = "cov must be 2 dimensional and square"; -static char __pyx_k167[] = "mean and cov must have same length"; -static char __pyx_k168[] = "numpy.dual"; - static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = "Return an array containing multivariate normally distributed random numbers\n with specified mean and covariance.\n\n multivariate_normal(mean, cov) -> random values\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\n\n mean must be a 1 dimensional array. cov must be a square two dimensional\n array with the same number of rows and columns as mean has elements.\n\n The first form returns a single 1-D array containing a multivariate\n normal.\n\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\n normal.\n "; static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -7946,7 +7932,7 @@ Py_ssize_t __pyx_5; PyObject *__pyx_6 = 0; static char *__pyx_argnames[] = {"mean","cov","size",0}; - __pyx_v_size = __pyx_k58; + __pyx_v_size = __pyx_d57; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_mean, &__pyx_v_cov, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_mean); @@ -7960,8 +7946,8 @@ __pyx_v_s = Py_None; Py_INCREF(Py_None); __pyx_v_v = Py_None; Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1470 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1470 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; goto __pyx_L1;} @@ -7974,8 +7960,8 @@ __pyx_v_mean = __pyx_3; __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1471 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1471 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; goto __pyx_L1;} __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; goto __pyx_L1;} @@ -7988,7 +7974,7 @@ __pyx_v_cov = __pyx_2; __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1472 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1472 */ __pyx_4 = __pyx_v_size == Py_None; if (__pyx_4) { __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1473; goto __pyx_L1;} @@ -8004,15 +7990,15 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1476 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1476 */ __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1476; goto __pyx_L1;} __pyx_5 = PyObject_Length(__pyx_3); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1476; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = (__pyx_5 != 1); if (__pyx_4) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1477; goto __pyx_L1;} - Py_INCREF(__pyx_k165p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k165p); + Py_INCREF(__pyx_k62p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k62p); __pyx_1 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1477; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_1, 0, 0); @@ -8022,7 +8008,7 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1478 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1478 */ __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;} __pyx_5 = PyObject_Length(__pyx_3); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; @@ -8041,8 +8027,8 @@ } if (__pyx_4) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; goto __pyx_L1;} - Py_INCREF(__pyx_k166p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k166p); + Py_INCREF(__pyx_k63p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k63p); __pyx_1 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_1, 0, 0); @@ -8052,7 +8038,7 @@ } __pyx_L4:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1480 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1480 */ __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; goto __pyx_L1;} __pyx_3 = __Pyx_GetItemInt(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; @@ -8065,8 +8051,8 @@ Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_4) { __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; goto __pyx_L1;} - Py_INCREF(__pyx_k167p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k167p); + Py_INCREF(__pyx_k64p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k64p); __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_3, 0, 0); @@ -8076,7 +8062,7 @@ } __pyx_L5:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1483 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1483 */ __pyx_4 = PyObject_IsInstance(__pyx_v_shape,((PyObject *)(&PyInt_Type))); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; goto __pyx_L1;} if (__pyx_4) { __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; goto __pyx_L1;} @@ -8089,7 +8075,7 @@ } __pyx_L6:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1485 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1485 */ __pyx_1 = PySequence_GetSlice(__pyx_v_shape, 0, PY_SSIZE_T_MAX); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1485; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1485; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); @@ -8100,7 +8086,7 @@ __pyx_v_final_shape = __pyx_2; __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1486 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1486 */ __pyx_1 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; goto __pyx_L1;} __pyx_2 = __Pyx_GetItemInt(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; goto __pyx_L1;} @@ -8113,9 +8099,9 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1490 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1490 */ __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;} - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_reduce); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; goto __pyx_L1;} @@ -8136,8 +8122,8 @@ __pyx_v_x = __pyx_2; __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1491 */ - __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1491 */ + __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;} __pyx_1 = PyObject_GetAttr(__pyx_6, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;} @@ -8161,11 +8147,11 @@ if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1500 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1500 */ __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1500; goto __pyx_L1;} Py_INCREF(__pyx_n_svd); PyList_SET_ITEM(__pyx_2, 0, __pyx_n_svd); - __pyx_1 = __Pyx_Import(__pyx_k168p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1500; goto __pyx_L1;} + __pyx_1 = __Pyx_Import(__pyx_k68p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1500; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_svd); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1500; goto __pyx_L1;} Py_DECREF(__pyx_v_svd); @@ -8173,7 +8159,7 @@ __pyx_3 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1502 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1502 */ __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;} Py_INCREF(__pyx_v_cov); PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_cov); @@ -8196,11 +8182,11 @@ if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1503 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1503 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;} __pyx_6 = PyObject_GetAttr(__pyx_3, __pyx_n_dot); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;} __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_sqrt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; goto __pyx_L1;} @@ -8223,8 +8209,8 @@ __pyx_v_x = __pyx_2; __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1506 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1506 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; goto __pyx_L1;} __pyx_6 = PyObject_GetAttr(__pyx_1, __pyx_n_add); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; goto __pyx_L1;} @@ -8239,7 +8225,7 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1507 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1507 */ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; goto __pyx_L1;} Py_INCREF(__pyx_v_final_shape); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_final_shape); @@ -8248,7 +8234,7 @@ if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1508 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1508 */ Py_INCREF(__pyx_v_x); __pyx_r = __pyx_v_x; goto __pyx_L0; @@ -8277,12 +8263,6 @@ return __pyx_r; } -static PyObject *__pyx_n_zeros; - -static PyObject *__pyx_k170p; - -static char __pyx_k170[] = "sum(pvals[:-1]) > 1.0"; - static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_multinomial[] = "Multinomial distribution.\n\n multinomial(n, pvals, size=None) -> random values\n\n pvals is a sequence of probabilities that should sum to 1 (however, the\n last element is always assumed to account for the remaining probability\n as long as sum(pvals[:-1]) <= 1).\n "; static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -8308,7 +8288,7 @@ PyObject *__pyx_5 = 0; long __pyx_6; static char *__pyx_argnames[] = {"n","pvals","size",0}; - __pyx_v_size = __pyx_k59; + __pyx_v_size = __pyx_d58; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "lO|O", __pyx_argnames, &__pyx_v_n, &__pyx_v_pvals, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_pvals); @@ -8318,26 +8298,26 @@ __pyx_v_shape = Py_None; Py_INCREF(Py_None); __pyx_v_multin = Py_None; Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1526 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1526 */ __pyx_1 = PyObject_Length(__pyx_v_pvals); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; goto __pyx_L1;} __pyx_v_d = __pyx_1; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1527 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1527 */ __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_pvals,NPY_DOUBLE,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1527; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)arrayObject_parr)); arrayObject_parr = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1528 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1528 */ __pyx_v_pix = ((double *)arrayObject_parr->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1530 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1530 */ __pyx_3 = (__pyx_f_6mtrand_kahan_sum(__pyx_v_pix,(__pyx_v_d - 1)) > (1.0 + 1e-12)); if (__pyx_3) { __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; goto __pyx_L1;} - Py_INCREF(__pyx_k170p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k170p); + Py_INCREF(__pyx_k72p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k72p); __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __Pyx_Raise(__pyx_4, 0, 0); @@ -8347,7 +8327,7 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1533 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1533 */ __pyx_3 = __pyx_v_size == Py_None; if (__pyx_3) { __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1534; goto __pyx_L1;} @@ -8391,8 +8371,8 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1540 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1540 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; goto __pyx_L1;} @@ -8407,39 +8387,39 @@ __pyx_v_multin = __pyx_5; __pyx_5 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1541 */ - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_multin))); + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1541 */ + Py_INCREF(__pyx_v_multin); Py_DECREF(((PyObject *)arrayObject_mnarr)); arrayObject_mnarr = ((PyArrayObject *)__pyx_v_multin); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1542 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1542 */ __pyx_v_mnix = ((long *)arrayObject_mnarr->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1543 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1543 */ __pyx_v_i = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1544 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1544 */ while (1) { __pyx_3 = (__pyx_v_i < PyArray_SIZE(arrayObject_mnarr)); if (!__pyx_3) break; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1545 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1545 */ __pyx_v_Sum = 1.0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1546 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1546 */ __pyx_v_dn = __pyx_v_n; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1547 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1547 */ __pyx_6 = (__pyx_v_d - 1); for (__pyx_v_j = 0; __pyx_v_j < __pyx_6; ++__pyx_v_j) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1548 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1548 */ (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]) = rk_binomial(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,__pyx_v_dn,((__pyx_v_pix[__pyx_v_j]) / __pyx_v_Sum)); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1549 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1549 */ __pyx_v_dn = (__pyx_v_dn - (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1550 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1550 */ __pyx_3 = (__pyx_v_dn <= 0); if (__pyx_3) { goto __pyx_L7; @@ -8447,12 +8427,12 @@ } __pyx_L8:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1552 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1552 */ __pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j])); } __pyx_L7:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1553 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1553 */ __pyx_3 = (__pyx_v_dn > 0); if (__pyx_3) { (__pyx_v_mnix[((__pyx_v_i + __pyx_v_d) - 1)]) = __pyx_v_dn; @@ -8460,11 +8440,11 @@ } __pyx_L9:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1556 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1556 */ __pyx_v_i = (__pyx_v_i + __pyx_v_d); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1558 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1558 */ Py_INCREF(__pyx_v_multin); __pyx_r = __pyx_v_multin; goto __pyx_L0; @@ -8512,7 +8492,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"alpha","size",0}; - __pyx_v_size = __pyx_k60; + __pyx_v_size = __pyx_d59; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_alpha, &__pyx_v_size)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_alpha); @@ -8522,21 +8502,21 @@ __pyx_v_shape = Py_None; Py_INCREF(Py_None); __pyx_v_diric = Py_None; Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1621 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1621 */ __pyx_1 = PyObject_Length(__pyx_v_alpha); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; goto __pyx_L1;} __pyx_v_k = __pyx_1; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1622 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1622 */ __pyx_2 = PyArray_ContiguousFromObject(__pyx_v_alpha,NPY_DOUBLE,1,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(__pyx_2); Py_DECREF(((PyObject *)__pyx_v_alpha_arr)); __pyx_v_alpha_arr = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1623 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1623 */ __pyx_v_alpha_data = ((double *)__pyx_v_alpha_arr->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1625 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1625 */ __pyx_3 = __pyx_v_size == Py_None; if (__pyx_3) { __pyx_2 = PyInt_FromLong(__pyx_v_k); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1626; goto __pyx_L1;} @@ -8580,11 +8560,11 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1632 */ - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1632 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;} __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_float64); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; goto __pyx_L1;} @@ -8599,51 +8579,51 @@ __pyx_v_diric = __pyx_5; __pyx_5 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1633 */ - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_diric))); + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1633 */ + Py_INCREF(__pyx_v_diric); Py_DECREF(((PyObject *)__pyx_v_val_arr)); __pyx_v_val_arr = ((PyArrayObject *)__pyx_v_diric); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1634 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1634 */ __pyx_v_val_data = ((double *)__pyx_v_val_arr->data); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1636 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1636 */ __pyx_v_i = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1637 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1637 */ __pyx_v_totsize = PyArray_SIZE(__pyx_v_val_arr); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1638 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1638 */ while (1) { __pyx_3 = (__pyx_v_i < __pyx_v_totsize); if (!__pyx_3) break; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1639 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1639 */ __pyx_v_acc = 0.0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1640 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1640 */ for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_k; ++__pyx_v_j) { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1641 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1641 */ (__pyx_v_val_data[(__pyx_v_i + __pyx_v_j)]) = rk_standard_gamma(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,(__pyx_v_alpha_data[__pyx_v_j])); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1642 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1642 */ __pyx_v_acc = (__pyx_v_acc + (__pyx_v_val_data[(__pyx_v_i + __pyx_v_j)])); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1643 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1643 */ __pyx_v_invacc = (1 / __pyx_v_acc); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1644 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1644 */ for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_k; ++__pyx_v_j) { (__pyx_v_val_data[(__pyx_v_i + __pyx_v_j)]) = ((__pyx_v_val_data[(__pyx_v_i + __pyx_v_j)]) * __pyx_v_invacc); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1646 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1646 */ __pyx_v_i = (__pyx_v_i + __pyx_v_k); } - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1648 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1648 */ Py_INCREF(__pyx_v_diric); __pyx_r = __pyx_v_diric; goto __pyx_L0; @@ -8667,9 +8647,6 @@ return __pyx_r; } -static PyObject *__pyx_n_copy; - - static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_shuffle[] = "Modify a sequence in-place by shuffling its contents.\n\n shuffle(x)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -8688,11 +8665,11 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_x); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1659 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1659 */ __pyx_1 = PyObject_Length(__pyx_v_x); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; goto __pyx_L1;} __pyx_v_i = (__pyx_1 - 1); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1660 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1660 */ /*try:*/ { __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; goto __pyx_L2;} __pyx_1 = PyObject_Length(__pyx_2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; goto __pyx_L2;} @@ -8703,7 +8680,7 @@ __pyx_L2:; Py_XDECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1662 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1662 */ /*except:*/ { __Pyx_AddTraceback("mtrand.shuffle"); if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; goto __pyx_L1;} @@ -8715,17 +8692,17 @@ } __pyx_L3:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1665 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1665 */ __pyx_5 = (__pyx_v_j == 0); if (__pyx_5) { while (1) { __pyx_5 = (__pyx_v_i > 0); if (!__pyx_5) break; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1668 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1668 */ __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1669 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1669 */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; goto __pyx_L1;} __pyx_3 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; goto __pyx_L1;} if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_i, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; goto __pyx_L1;} @@ -8733,30 +8710,30 @@ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1670 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1670 */ __pyx_v_i = (__pyx_v_i - 1); } goto __pyx_L4; } /*else*/ { - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1673 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1673 */ __pyx_4 = __Pyx_GetItemInt(__pyx_v_x, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; goto __pyx_L1;} __pyx_5 = PyObject_HasAttr(__pyx_4,__pyx_n_copy); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_v_copy = __pyx_5; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1674 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1674 */ __pyx_5 = __pyx_v_copy; if (__pyx_5) { while (1) { __pyx_5 = (__pyx_v_i > 0); if (!__pyx_5) break; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1676 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1676 */ __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1677 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1677 */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_copy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; @@ -8772,7 +8749,7 @@ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1678 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1678 */ __pyx_v_i = (__pyx_v_i - 1); } goto __pyx_L7; @@ -8782,10 +8759,10 @@ __pyx_5 = (__pyx_v_i > 0); if (!__pyx_5) break; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1681 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1681 */ __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1682 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1682 */ __pyx_3 = __Pyx_GetItemInt(__pyx_v_x, __pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;} __pyx_4 = PySequence_GetSlice(__pyx_3, 0, PY_SSIZE_T_MAX); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; @@ -8797,7 +8774,7 @@ if (__Pyx_SetItemInt(__pyx_v_x, __pyx_v_j, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1683 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1683 */ __pyx_v_i = (__pyx_v_i - 1); } } @@ -8819,8 +8796,6 @@ return __pyx_r; } -static PyObject *__pyx_n_arange; - static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6mtrand_11RandomState_permutation[] = "Given an integer, return a shuffled sequence of integers >= 0 and\n < x; given a sequence, return a shuffled array copy.\n\n permutation(x)\n "; static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -8837,8 +8812,8 @@ Py_INCREF(__pyx_v_x); __pyx_v_arr = Py_None; Py_INCREF(Py_None); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1691 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;} + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1691 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_integer); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;} @@ -8849,7 +8824,7 @@ __pyx_3 = PyObject_IsInstance(__pyx_v_x,__pyx_1); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; goto __pyx_L1;} __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_arange); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; goto __pyx_L1;} @@ -8864,7 +8839,7 @@ goto __pyx_L2; } /*else*/ { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_np); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; goto __pyx_L1;} @@ -8879,7 +8854,7 @@ } __pyx_L2:; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1695 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1695 */ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; goto __pyx_L1;} __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; goto __pyx_L1;} Py_INCREF(__pyx_v_arr); @@ -8889,7 +8864,7 @@ Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1696 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1696 */ Py_INCREF(__pyx_v_arr); __pyx_r = __pyx_v_arr; goto __pyx_L0; @@ -8909,197 +8884,6 @@ return __pyx_r; } -static __Pyx_InternTabEntry __pyx_intern_tab[] = { - {&__pyx_n_MT19937, "MT19937"}, - {&__pyx_n___RandomState_ctor, "__RandomState_ctor"}, - {&__pyx_n__rand, "_rand"}, - {&__pyx_n__sp, "_sp"}, - {&__pyx_n_add, "add"}, - {&__pyx_n_any, "any"}, - {&__pyx_n_append, "append"}, - {&__pyx_n_arange, "arange"}, - {&__pyx_n_array, "array"}, - {&__pyx_n_asarray, "asarray"}, - {&__pyx_n_beta, "beta"}, - {&__pyx_n_binomial, "binomial"}, - {&__pyx_n_bytes, "bytes"}, - {&__pyx_n_chisquare, "chisquare"}, - {&__pyx_n_copy, "copy"}, - {&__pyx_n_dirichlet, "dirichlet"}, - {&__pyx_n_dot, "dot"}, - {&__pyx_n_empty, "empty"}, - {&__pyx_n_equal, "equal"}, - {&__pyx_n_exponential, "exponential"}, - {&__pyx_n_f, "f"}, - {&__pyx_n_float64, "float64"}, - {&__pyx_n_gamma, "gamma"}, - {&__pyx_n_geometric, "geometric"}, - {&__pyx_n_get_state, "get_state"}, - {&__pyx_n_greater, "greater"}, - {&__pyx_n_gumbel, "gumbel"}, - {&__pyx_n_hypergeometric, "hypergeometric"}, - {&__pyx_n_integer, "integer"}, - {&__pyx_n_laplace, "laplace"}, - {&__pyx_n_less, "less"}, - {&__pyx_n_less_equal, "less_equal"}, - {&__pyx_n_logistic, "logistic"}, - {&__pyx_n_lognormal, "lognormal"}, - {&__pyx_n_logseries, "logseries"}, - {&__pyx_n_multinomial, "multinomial"}, - {&__pyx_n_multiply, "multiply"}, - {&__pyx_n_multivariate_normal, "multivariate_normal"}, - {&__pyx_n_negative_binomial, "negative_binomial"}, - {&__pyx_n_noncentral_chisquare, "noncentral_chisquare"}, - {&__pyx_n_noncentral_f, "noncentral_f"}, - {&__pyx_n_normal, "normal"}, - {&__pyx_n_numpy, "numpy"}, - {&__pyx_n_pareto, "pareto"}, - {&__pyx_n_permutation, "permutation"}, - {&__pyx_n_poisson, "poisson"}, - {&__pyx_n_power, "power"}, - {&__pyx_n_rand, "rand"}, - {&__pyx_n_randint, "randint"}, - {&__pyx_n_randn, "randn"}, - {&__pyx_n_random, "random"}, - {&__pyx_n_random_integers, "random_integers"}, - {&__pyx_n_random_sample, "random_sample"}, - {&__pyx_n_rayleigh, "rayleigh"}, - {&__pyx_n_reduce, "reduce"}, - {&__pyx_n_seed, "seed"}, - {&__pyx_n_set_state, "set_state"}, - {&__pyx_n_shape, "shape"}, - {&__pyx_n_shuffle, "shuffle"}, - {&__pyx_n_size, "size"}, - {&__pyx_n_sqrt, "sqrt"}, - {&__pyx_n_standard_cauchy, "standard_cauchy"}, - {&__pyx_n_standard_exponential, "standard_exponential"}, - {&__pyx_n_standard_gamma, "standard_gamma"}, - {&__pyx_n_standard_normal, "standard_normal"}, - {&__pyx_n_standard_t, "standard_t"}, - {&__pyx_n_subtract, "subtract"}, - {&__pyx_n_svd, "svd"}, - {&__pyx_n_triangular, "triangular"}, - {&__pyx_n_uint, "uint"}, - {&__pyx_n_uint32, "uint32"}, - {&__pyx_n_uniform, "uniform"}, - {&__pyx_n_vonmises, "vonmises"}, - {&__pyx_n_wald, "wald"}, - {&__pyx_n_weibull, "weibull"}, - {&__pyx_n_zeros, "zeros"}, - {&__pyx_n_zipf, "zipf"}, - {0, 0} -}; - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)}, - {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)}, - {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)}, - {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)}, - {&__pyx_k65p, __pyx_k65, sizeof(__pyx_k65)}, - {&__pyx_k66p, __pyx_k66, sizeof(__pyx_k66)}, - {&__pyx_k69p, __pyx_k69, sizeof(__pyx_k69)}, - {&__pyx_k70p, __pyx_k70, sizeof(__pyx_k70)}, - {&__pyx_k71p, __pyx_k71, sizeof(__pyx_k71)}, - {&__pyx_k73p, __pyx_k73, sizeof(__pyx_k73)}, - {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)}, - {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)}, - {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)}, - {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)}, - {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)}, - {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)}, - {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)}, - {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)}, - {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)}, - {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)}, - {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)}, - {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)}, - {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)}, - {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)}, - {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)}, - {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)}, - {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)}, - {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)}, - {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)}, - {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)}, - {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)}, - {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)}, - {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)}, - {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)}, - {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)}, - {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)}, - {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)}, - {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)}, - {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)}, - {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)}, - {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)}, - {&__pyx_k105p, __pyx_k105, sizeof(__pyx_k105)}, - {&__pyx_k106p, __pyx_k106, sizeof(__pyx_k106)}, - {&__pyx_k107p, __pyx_k107, sizeof(__pyx_k107)}, - {&__pyx_k108p, __pyx_k108, sizeof(__pyx_k108)}, - {&__pyx_k109p, __pyx_k109, sizeof(__pyx_k109)}, - {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)}, - {&__pyx_k111p, __pyx_k111, sizeof(__pyx_k111)}, - {&__pyx_k112p, __pyx_k112, sizeof(__pyx_k112)}, - {&__pyx_k113p, __pyx_k113, sizeof(__pyx_k113)}, - {&__pyx_k114p, __pyx_k114, sizeof(__pyx_k114)}, - {&__pyx_k115p, __pyx_k115, sizeof(__pyx_k115)}, - {&__pyx_k116p, __pyx_k116, sizeof(__pyx_k116)}, - {&__pyx_k117p, __pyx_k117, sizeof(__pyx_k117)}, - {&__pyx_k118p, __pyx_k118, sizeof(__pyx_k118)}, - {&__pyx_k119p, __pyx_k119, sizeof(__pyx_k119)}, - {&__pyx_k120p, __pyx_k120, sizeof(__pyx_k120)}, - {&__pyx_k121p, __pyx_k121, sizeof(__pyx_k121)}, - {&__pyx_k122p, __pyx_k122, sizeof(__pyx_k122)}, - {&__pyx_k123p, __pyx_k123, sizeof(__pyx_k123)}, - {&__pyx_k124p, __pyx_k124, sizeof(__pyx_k124)}, - {&__pyx_k125p, __pyx_k125, sizeof(__pyx_k125)}, - {&__pyx_k126p, __pyx_k126, sizeof(__pyx_k126)}, - {&__pyx_k127p, __pyx_k127, sizeof(__pyx_k127)}, - {&__pyx_k128p, __pyx_k128, sizeof(__pyx_k128)}, - {&__pyx_k129p, __pyx_k129, sizeof(__pyx_k129)}, - {&__pyx_k130p, __pyx_k130, sizeof(__pyx_k130)}, - {&__pyx_k131p, __pyx_k131, sizeof(__pyx_k131)}, - {&__pyx_k132p, __pyx_k132, sizeof(__pyx_k132)}, - {&__pyx_k133p, __pyx_k133, sizeof(__pyx_k133)}, - {&__pyx_k134p, __pyx_k134, sizeof(__pyx_k134)}, - {&__pyx_k135p, __pyx_k135, sizeof(__pyx_k135)}, - {&__pyx_k136p, __pyx_k136, sizeof(__pyx_k136)}, - {&__pyx_k137p, __pyx_k137, sizeof(__pyx_k137)}, - {&__pyx_k138p, __pyx_k138, sizeof(__pyx_k138)}, - {&__pyx_k139p, __pyx_k139, sizeof(__pyx_k139)}, - {&__pyx_k140p, __pyx_k140, sizeof(__pyx_k140)}, - {&__pyx_k141p, __pyx_k141, sizeof(__pyx_k141)}, - {&__pyx_k142p, __pyx_k142, sizeof(__pyx_k142)}, - {&__pyx_k143p, __pyx_k143, sizeof(__pyx_k143)}, - {&__pyx_k144p, __pyx_k144, sizeof(__pyx_k144)}, - {&__pyx_k145p, __pyx_k145, sizeof(__pyx_k145)}, - {&__pyx_k146p, __pyx_k146, sizeof(__pyx_k146)}, - {&__pyx_k147p, __pyx_k147, sizeof(__pyx_k147)}, - {&__pyx_k148p, __pyx_k148, sizeof(__pyx_k148)}, - {&__pyx_k149p, __pyx_k149, sizeof(__pyx_k149)}, - {&__pyx_k150p, __pyx_k150, sizeof(__pyx_k150)}, - {&__pyx_k151p, __pyx_k151, sizeof(__pyx_k151)}, - {&__pyx_k152p, __pyx_k152, sizeof(__pyx_k152)}, - {&__pyx_k153p, __pyx_k153, sizeof(__pyx_k153)}, - {&__pyx_k154p, __pyx_k154, sizeof(__pyx_k154)}, - {&__pyx_k155p, __pyx_k155, sizeof(__pyx_k155)}, - {&__pyx_k156p, __pyx_k156, sizeof(__pyx_k156)}, - {&__pyx_k157p, __pyx_k157, sizeof(__pyx_k157)}, - {&__pyx_k158p, __pyx_k158, sizeof(__pyx_k158)}, - {&__pyx_k159p, __pyx_k159, sizeof(__pyx_k159)}, - {&__pyx_k160p, __pyx_k160, sizeof(__pyx_k160)}, - {&__pyx_k161p, __pyx_k161, sizeof(__pyx_k161)}, - {&__pyx_k162p, __pyx_k162, sizeof(__pyx_k162)}, - {&__pyx_k163p, __pyx_k163, sizeof(__pyx_k163)}, - {&__pyx_k164p, __pyx_k164, sizeof(__pyx_k164)}, - {&__pyx_k165p, __pyx_k165, sizeof(__pyx_k165)}, - {&__pyx_k166p, __pyx_k166, sizeof(__pyx_k166)}, - {&__pyx_k167p, __pyx_k167, sizeof(__pyx_k167)}, - {&__pyx_k168p, __pyx_k168, sizeof(__pyx_k168)}, - {&__pyx_k170p, __pyx_k170, sizeof(__pyx_k170)}, - {0, 0, 0} -}; - static PyObject *__pyx_tp_new_6mtrand_RandomState(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; @@ -9325,7 +9109,6 @@ __pyx_b = PyImport_AddModule("__builtin__"); if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}; if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}; - if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}; if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}; __pyx_ptype_6mtrand_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_6mtrand_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; goto __pyx_L1;} __pyx_ptype_6mtrand_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_6mtrand_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 79; goto __pyx_L1;} @@ -9335,551 +9118,551 @@ if (PyObject_SetAttrString(__pyx_m, "RandomState", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; goto __pyx_L1;} __pyx_ptype_6mtrand_RandomState = &__pyx_type_6mtrand_RandomState; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":120 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":120 */ import_array(); - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":122 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":122 */ __pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n__sp, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_np, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":489 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":489 */ Py_INCREF(Py_None); - __pyx_k2 = Py_None; + __pyx_d1 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":499 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":499 */ Py_INCREF(Py_None); - __pyx_k3 = Py_None; + __pyx_d2 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":581 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":581 */ Py_INCREF(Py_None); - __pyx_k4 = Py_None; + __pyx_d3 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":588 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":588 */ Py_INCREF(Py_None); - __pyx_k5 = Py_None; + __pyx_d4 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":595 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":595 */ Py_INCREF(Py_None); - __pyx_k6 = Py_None; + __pyx_d5 = Py_None; Py_INCREF(Py_None); - __pyx_k7 = Py_None; + __pyx_d6 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":640 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":640 */ __pyx_1 = PyFloat_FromDouble(0.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} - __pyx_k8 = __pyx_1; + __pyx_d7 = __pyx_1; __pyx_1 = 0; __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} - __pyx_k9 = __pyx_2; + __pyx_d8 = __pyx_2; __pyx_2 = 0; Py_INCREF(Py_None); - __pyx_k10 = Py_None; + __pyx_d9 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":693 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":693 */ Py_INCREF(Py_None); - __pyx_k11 = Py_None; + __pyx_d10 = Py_None; Py_INCREF(Py_None); - __pyx_k12 = Py_None; + __pyx_d11 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":706 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":706 */ Py_INCREF(Py_None); - __pyx_k13 = Py_None; + __pyx_d12 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":713 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":713 */ __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; goto __pyx_L1;} - __pyx_k14 = __pyx_3; + __pyx_d13 = __pyx_3; __pyx_3 = 0; __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; goto __pyx_L1;} - __pyx_k15 = __pyx_4; + __pyx_d14 = __pyx_4; __pyx_4 = 0; Py_INCREF(Py_None); - __pyx_k16 = Py_None; + __pyx_d15 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":736 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":736 */ Py_INCREF(Py_None); - __pyx_k17 = Py_None; + __pyx_d16 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":763 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":763 */ __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;} - __pyx_k18 = __pyx_5; + __pyx_d17 = __pyx_5; __pyx_5 = 0; Py_INCREF(Py_None); - __pyx_k19 = Py_None; + __pyx_d18 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":784 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":784 */ Py_INCREF(Py_None); - __pyx_k20 = Py_None; + __pyx_d19 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":791 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":791 */ Py_INCREF(Py_None); - __pyx_k21 = Py_None; + __pyx_d20 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":811 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":811 */ __pyx_6 = PyFloat_FromDouble(1.0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;} - __pyx_k22 = __pyx_6; + __pyx_d21 = __pyx_6; __pyx_6 = 0; Py_INCREF(Py_None); - __pyx_k23 = Py_None; + __pyx_d22 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":837 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":837 */ Py_INCREF(Py_None); - __pyx_k24 = Py_None; + __pyx_d23 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":864 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":864 */ Py_INCREF(Py_None); - __pyx_k25 = Py_None; + __pyx_d24 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":900 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":900 */ Py_INCREF(Py_None); - __pyx_k26 = Py_None; + __pyx_d25 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":921 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":921 */ Py_INCREF(Py_None); - __pyx_k27 = Py_None; + __pyx_d26 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":949 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":949 */ Py_INCREF(Py_None); - __pyx_k28 = Py_None; + __pyx_d27 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":956 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":956 */ Py_INCREF(Py_None); - __pyx_k29 = Py_None; + __pyx_d28 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":977 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":977 */ Py_INCREF(Py_None); - __pyx_k30 = Py_None; + __pyx_d29 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1001 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1001 */ Py_INCREF(Py_None); - __pyx_k31 = Py_None; + __pyx_d30 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1022 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1022 */ Py_INCREF(Py_None); - __pyx_k32 = Py_None; + __pyx_d31 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1043 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1043 */ Py_INCREF(Py_None); - __pyx_k33 = Py_None; + __pyx_d32 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1064 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1064 */ __pyx_7 = PyFloat_FromDouble(0.0); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; goto __pyx_L1;} - __pyx_k34 = __pyx_7; + __pyx_d33 = __pyx_7; __pyx_7 = 0; __pyx_8 = PyFloat_FromDouble(1.0); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; goto __pyx_L1;} - __pyx_k35 = __pyx_8; + __pyx_d34 = __pyx_8; __pyx_8 = 0; Py_INCREF(Py_None); - __pyx_k36 = Py_None; + __pyx_d35 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1086 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1086 */ __pyx_9 = PyFloat_FromDouble(0.0); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; goto __pyx_L1;} - __pyx_k37 = __pyx_9; + __pyx_d36 = __pyx_9; __pyx_9 = 0; __pyx_10 = PyFloat_FromDouble(1.0); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; goto __pyx_L1;} - __pyx_k38 = __pyx_10; + __pyx_d37 = __pyx_10; __pyx_10 = 0; Py_INCREF(Py_None); - __pyx_k39 = Py_None; + __pyx_d38 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1108 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1108 */ __pyx_11 = PyFloat_FromDouble(0.0); if (!__pyx_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; goto __pyx_L1;} - __pyx_k40 = __pyx_11; + __pyx_d39 = __pyx_11; __pyx_11 = 0; __pyx_12 = PyFloat_FromDouble(1.0); if (!__pyx_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; goto __pyx_L1;} - __pyx_k41 = __pyx_12; + __pyx_d40 = __pyx_12; __pyx_12 = 0; Py_INCREF(Py_None); - __pyx_k42 = Py_None; + __pyx_d41 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1130 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1130 */ __pyx_13 = PyFloat_FromDouble(0.0); if (!__pyx_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; goto __pyx_L1;} - __pyx_k43 = __pyx_13; + __pyx_d42 = __pyx_13; __pyx_13 = 0; __pyx_14 = PyFloat_FromDouble(1.0); if (!__pyx_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; goto __pyx_L1;} - __pyx_k44 = __pyx_14; + __pyx_d43 = __pyx_14; __pyx_14 = 0; Py_INCREF(Py_None); - __pyx_k45 = Py_None; + __pyx_d44 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1159 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1159 */ __pyx_15 = PyFloat_FromDouble(1.0); if (!__pyx_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; goto __pyx_L1;} - __pyx_k46 = __pyx_15; + __pyx_d45 = __pyx_15; __pyx_15 = 0; Py_INCREF(Py_None); - __pyx_k47 = Py_None; + __pyx_d46 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1181 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1181 */ Py_INCREF(Py_None); - __pyx_k48 = Py_None; + __pyx_d47 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1209 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1209 */ Py_INCREF(Py_None); - __pyx_k49 = Py_None; + __pyx_d48 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1246 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1246 */ Py_INCREF(Py_None); - __pyx_k50 = Py_None; + __pyx_d49 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1278 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1278 */ Py_INCREF(Py_None); - __pyx_k51 = Py_None; + __pyx_d50 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1313 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1313 */ __pyx_16 = PyFloat_FromDouble(1.0); if (!__pyx_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; goto __pyx_L1;} - __pyx_k52 = __pyx_16; + __pyx_d51 = __pyx_16; __pyx_16 = 0; Py_INCREF(Py_None); - __pyx_k53 = Py_None; + __pyx_d52 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1333 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1333 */ Py_INCREF(Py_None); - __pyx_k54 = Py_None; + __pyx_d53 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1354 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1354 */ Py_INCREF(Py_None); - __pyx_k55 = Py_None; + __pyx_d54 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1381 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1381 */ Py_INCREF(Py_None); - __pyx_k56 = Py_None; + __pyx_d55 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1426 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1426 */ Py_INCREF(Py_None); - __pyx_k57 = Py_None; + __pyx_d56 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1452 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1452 */ Py_INCREF(Py_None); - __pyx_k58 = Py_None; + __pyx_d57 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1510 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1510 */ Py_INCREF(Py_None); - __pyx_k59 = Py_None; + __pyx_d58 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1560 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1560 */ Py_INCREF(Py_None); - __pyx_k60 = Py_None; + __pyx_d59 = Py_None; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1698 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1698 */ __pyx_17 = PyObject_CallObject(((PyObject *)__pyx_ptype_6mtrand_RandomState), 0); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1698; goto __pyx_L1;} if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_17) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1698; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1699 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1699 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_seed); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_seed, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1700 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1700 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_get_state); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1701 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1701 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_set_state); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1702 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1702 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_random_sample); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1703 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1703 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_randint); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1704 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1704 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_bytes); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1705 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1705 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_uniform); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1706 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1706 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_rand); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1707 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1707 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_randn); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1708 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1708 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_random_integers); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1709 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1709 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1710 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1710 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1711 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1711 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_beta); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1712 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1712 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_exponential); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1713 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1713 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_exponential); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1714 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1714 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_gamma); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1715 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1715 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_gamma); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1716 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1716 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_f); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1717 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1717 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_noncentral_f); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1718 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1718 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_chisquare); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1719 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1719 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_noncentral_chisquare); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1720 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1720 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_cauchy); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1721 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1721 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_standard_t); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1722 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1722 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_vonmises); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1723 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1723 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_pareto); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1724 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1724 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_weibull); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1725 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1725 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1725; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_power); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1725; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1725; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1726 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1726 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_laplace); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1727 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1727 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1727; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_gumbel); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1727; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1727; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1728 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1728 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1728; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_logistic); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1728; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1728; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1729 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1729 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1729; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_lognormal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1729; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1729; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1730 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1730 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_rayleigh); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1731 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1731 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_wald); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1732 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1732 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1732; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_triangular); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1732; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1732; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1734 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1734 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_binomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1735 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1735 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_negative_binomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1736 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1736 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_poisson); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1737 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1737 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_zipf); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1738 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1738 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_geometric); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1739 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1739 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_hypergeometric); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1740 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1740 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_logseries); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_logseries, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1742 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1742 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_multivariate_normal); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1743 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1743 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_multinomial); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1744 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1744 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_dirichlet); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_dirichlet, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1746 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1746 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_shuffle); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; goto __pyx_L1;} Py_DECREF(__pyx_18); __pyx_18 = 0; - /* "/Users/stefan/src/numpy/numpy/random/mtrand/mtrand.pyx":1747 */ + /* "/home/alan/numpy/numpy/random/mtrand/mtrand.pyx":1747 */ __pyx_17 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; goto __pyx_L1;} __pyx_18 = PyObject_GetAttr(__pyx_17, __pyx_n_permutation); if (!__pyx_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; goto __pyx_L1;} Py_DECREF(__pyx_17); __pyx_17 = 0; @@ -9919,136 +9702,6 @@ __pyx_f = __pyx_filenames; } -static int __Pyx_GetStarArgs( - PyObject **args, - PyObject **kwds, - char *kwd_list[], - Py_ssize_t nargs, - PyObject **args2, - PyObject **kwds2, - char rqd_kwds[]) -{ - PyObject *x = 0, *args1 = 0, *kwds1 = 0; - int i; - char **p; - - if (args2) - *args2 = 0; - if (kwds2) - *kwds2 = 0; - - if (args2) { - args1 = PyTuple_GetSlice(*args, 0, nargs); - if (!args1) - goto bad; - *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args)); - if (!*args2) - goto bad; - } - else if (PyTuple_GET_SIZE(*args) > nargs) { - int m = nargs; - int n = PyTuple_GET_SIZE(*args); - PyErr_Format(PyExc_TypeError, - "function takes at most %d positional arguments (%d given)", - m, n); - goto bad; - } - else { - args1 = *args; - Py_INCREF(args1); - } - - if (rqd_kwds && !*kwds) - for (i = 0, p = kwd_list; *p; i++, p++) - if (rqd_kwds[i]) - goto missing_kwarg; - - if (kwds2) { - if (*kwds) { - kwds1 = PyDict_New(); - if (!kwds1) - goto bad; - *kwds2 = PyDict_Copy(*kwds); - if (!*kwds2) - goto bad; - for (i = 0, p = kwd_list; *p; i++, p++) { - x = PyDict_GetItemString(*kwds, *p); - if (x) { - if (PyDict_SetItemString(kwds1, *p, x) < 0) - goto bad; - if (PyDict_DelItemString(*kwds2, *p) < 0) - goto bad; - } - else if (rqd_kwds && rqd_kwds[i]) - goto missing_kwarg; - } - } - else { - *kwds2 = PyDict_New(); - if (!*kwds2) - goto bad; - } - } - else { - kwds1 = *kwds; - Py_XINCREF(kwds1); - if (rqd_kwds && *kwds) - for (i = 0, p = kwd_list; *p; i++, p++) - if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p)) - goto missing_kwarg; - } - - *args = args1; - *kwds = kwds1; - return 0; -missing_kwarg: - PyErr_Format(PyExc_TypeError, - "required keyword argument '%s' is missing", *p); -bad: - Py_XDECREF(args1); - Py_XDECREF(kwds1); - if (args2) { - Py_XDECREF(*args2); - } - if (kwds2) { - Py_XDECREF(*kwds2); - } - return -1; -} - -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { - PyObject *__import__ = 0; - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); - if (!__import__) - goto bad; - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - module = PyObject_CallFunction(__import__, "OOOO", - name, global_dict, empty_dict, list); -bad: - Py_XDECREF(empty_list); - Py_XDECREF(__import__); - Py_XDECREF(empty_dict); - return module; -} - static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { PyObject *result; result = PyObject_GetAttr(dict, name); @@ -10184,6 +9837,103 @@ return -1; } +static int __Pyx_GetStarArgs( + PyObject **args, + PyObject **kwds, + char *kwd_list[], + Py_ssize_t nargs, + PyObject **args2, + PyObject **kwds2, + char rqd_kwds[]) +{ + PyObject *x = 0, *args1 = 0, *kwds1 = 0; + int i; + char **p; + + if (args2) + *args2 = 0; + if (kwds2) + *kwds2 = 0; + + if (args2) { + args1 = PyTuple_GetSlice(*args, 0, nargs); + if (!args1) + goto bad; + *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args)); + if (!*args2) + goto bad; + } + else if (PyTuple_GET_SIZE(*args) > nargs) { + int m = nargs; + int n = PyTuple_GET_SIZE(*args); + PyErr_Format(PyExc_TypeError, + "function takes at most %d positional arguments (%d given)", + m, n); + goto bad; + } + else { + args1 = *args; + Py_INCREF(args1); + } + + if (rqd_kwds && !*kwds) + for (i = 0, p = kwd_list; *p; i++, p++) + if (rqd_kwds[i]) + goto missing_kwarg; + + if (kwds2) { + if (*kwds) { + kwds1 = PyDict_New(); + if (!kwds1) + goto bad; + *kwds2 = PyDict_Copy(*kwds); + if (!*kwds2) + goto bad; + for (i = 0, p = kwd_list; *p; i++, p++) { + x = PyDict_GetItemString(*kwds, *p); + if (x) { + if (PyDict_SetItemString(kwds1, *p, x) < 0) + goto bad; + if (PyDict_DelItemString(*kwds2, *p) < 0) + goto bad; + } + else if (rqd_kwds && rqd_kwds[i]) + goto missing_kwarg; + } + } + else { + *kwds2 = PyDict_New(); + if (!*kwds2) + goto bad; + } + } + else { + kwds1 = *kwds; + Py_XINCREF(kwds1); + if (rqd_kwds && *kwds) + for (i = 0, p = kwd_list; *p; i++, p++) + if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p)) + goto missing_kwarg; + } + + *args = args1; + *kwds = kwds1; + return 0; +missing_kwarg: + PyErr_Format(PyExc_TypeError, + "required keyword argument '%s' is missing", *p); +bad: + Py_XDECREF(args1); + Py_XDECREF(kwds1); + if (args2) { + Py_XDECREF(*args2); + } + if (kwds2) { + Py_XDECREF(*kwds2); + } + return -1; +} + static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (!type) { PyErr_Format(PyExc_SystemError, "Missing type object"); @@ -10196,6 +9946,39 @@ return 0; } +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { + PyObject *__import__ = 0; + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); + if (!__import__) + goto bad; + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + module = PyObject_CallFunction(__import__, "OOOO", + name, global_dict, empty_dict, list); +bad: + Py_XDECREF(empty_list); + Py_XDECREF(__import__); + Py_XDECREF(empty_dict); + return module; +} + static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v) { PyTypeObject *t = o->ob_type; int r; @@ -10211,21 +9994,13 @@ return r; } -static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { - while (t->p) { - *t->p = PyString_InternFromString(t->s); - if (!*t->p) - return -1; - ++t; - } - return 0; -} - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); if (!*t->p) return -1; + if (t->i) + PyString_InternInPlace(t->p); ++t; } return 0; From numpy-svn at scipy.org Fri Jul 25 14:35:20 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 25 Jul 2008 13:35:20 -0500 (CDT) Subject: [Numpy-svn] r5526 - in trunk/tools: . osxbuild osxbuild/docs Message-ID: <20080725183520.0DF6C39C8E6@scipy.org> Author: chris.burns Date: 2008-07-25 13:35:17 -0500 (Fri, 25 Jul 2008) New Revision: 5526 Added: trunk/tools/osxbuild/ trunk/tools/osxbuild/README.txt trunk/tools/osxbuild/build.py trunk/tools/osxbuild/docs/ trunk/tools/osxbuild/docs/README.txt Log: Add script for building osx installer. Added: trunk/tools/osxbuild/README.txt =================================================================== --- trunk/tools/osxbuild/README.txt 2008-07-25 16:43:32 UTC (rev 5525) +++ trunk/tools/osxbuild/README.txt 2008-07-25 18:35:17 UTC (rev 5526) @@ -0,0 +1,6 @@ +This directory contains the script to build a universal binary for +OSX. The binaries work on OSX 10.4 and 10.5. + + - bdist_mpkg v0.4.3 is required + +See the docstring in build.py for more details. Added: trunk/tools/osxbuild/build.py =================================================================== --- trunk/tools/osxbuild/build.py 2008-07-25 16:43:32 UTC (rev 5525) +++ trunk/tools/osxbuild/build.py 2008-07-25 18:35:17 UTC (rev 5526) @@ -0,0 +1,102 @@ +"""Python script to build the OSX universal binaries. + +This is a simple script, most of the heavy lifting is done in bdist_mpkg. + +Requires a svn version of numpy is installed, svn is used to revert +file changes made to the docs for the end-user install. Installer is +built using sudo so file permissions are correct when installed on +user system. Script will prompt for sudo pwd. + +""" + +import os +import shutil +import subprocess +from getpass import getuser + +SRC_DIR = '../../' + +USER_README = 'docs/README.txt' +DEV_README = SRC_DIR + 'README.txt' + +BUILD_DIR = 'build' +DIST_DIR = 'dist' + +def remove_dirs(): + print 'Removing old build and distribution directories...' + print """The distribution is built as root, so the files have the correct + permissions when installed by the user. Chown them to user for removal.""" + if os.path.exists(BUILD_DIR): + cmd = 'sudo chown -R %s %s' % (getuser(), BUILD_DIR) + shellcmd(cmd) + shutil.rmtree(BUILD_DIR) + if os.path.exists(DIST_DIR): + cmd = 'sudo chown -R %s %s' % (getuser(), DIST_DIR) + shellcmd(cmd) + shutil.rmtree(DIST_DIR) + +def build_dist(): + print 'Building distribution... (using sudo)' + cmd = 'sudo python setupegg.py bdist_mpkg' + shellcmd(cmd) + +def build_dmg(): + print 'Building disk image...' + # Since we removed the dist directory at the start of the script, + # our pkg should be the only file there. + pkg = os.listdir(DIST_DIR)[0] + fn, ext = os.path.splitext(pkg) + dmg = fn + '.dmg' + srcfolder = os.path.join(DIST_DIR, pkg) + dstfolder = os.path.join(DIST_DIR, dmg) + # build disk image + cmd = 'sudo hdiutil create -srcfolder %s %s' % (srcfolder, dstfolder) + shellcmd(cmd) + +def copy_readme(): + """Copy a user README with info regarding the website, instead of + the developer README which tells one how to build the source. + """ + print 'Copy user README.txt for installer.' + shutil.copy(USER_README, DEV_README) + +def revert_readme(): + """Revert the developer README.""" + print 'Reverting README.txt...' + cmd = 'svn revert %s' % DEV_README + shellcmd(cmd) + +def shellcmd(cmd, verbose=True): + """Call a shell command.""" + if verbose: + print cmd + try: + subprocess.check_call(cmd, shell=True) + except subprocess.CalledProcessError, err: + msg = """ + Error while executing a shell command. + %s + """ % str(err) + raise Exception(msg) + +def build(): + # update end-user documentation + copy_readme() + shellcmd("svn stat %s"%DEV_README) + + # change to source directory + cwd = os.getcwd() + os.chdir(SRC_DIR) + + # build distribution + remove_dirs() + build_dist() + build_dmg() + + # change back to original directory + os.chdir(cwd) + # restore developer documentation + revert_readme() + +if __name__ == '__main__': + build() Added: trunk/tools/osxbuild/docs/README.txt =================================================================== --- trunk/tools/osxbuild/docs/README.txt 2008-07-25 16:43:32 UTC (rev 5525) +++ trunk/tools/osxbuild/docs/README.txt 2008-07-25 18:35:17 UTC (rev 5526) @@ -0,0 +1,22 @@ +NumPy is the fundamental package needed for scientific computing with Python. +This package contains: + + * a powerful N-dimensional array object + * sophisticated (broadcasting) functions + * tools for integrating C/C++ and Fortran code + * useful linear algebra, Fourier transform, and random number capabilities. + +It derives from the old Numeric code base and can be used as a replacement for Numeric. It also adds the features introduced by numarray and can be used to replace numarray. + +More information can be found at the website: + +http://scipy.org/NumPy + +After installation, tests can be run with: + +python -c 'import numpy; numpy.test()' + +The most current development version is always available from our +subversion repository: + +http://svn.scipy.org/svn/numpy/trunk From numpy-svn at scipy.org Sat Jul 26 01:00:44 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:00:44 -0500 (CDT) Subject: [Numpy-svn] r5527 - vendor/tools Message-ID: <20080726050044.6431439C707@scipy.org> Author: cdavid Date: 2008-07-26 00:00:39 -0500 (Sat, 26 Jul 2008) New Revision: 5527 Added: vendor/tools/sse2.cfg Modified: vendor/tools/build.py Log: Use a config file to switch more easily between configurations. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-25 18:35:17 UTC (rev 5526) +++ vendor/tools/build.py 2008-07-26 05:00:39 UTC (rev 5527) @@ -3,21 +3,22 @@ from subprocess import Popen import shutil import os.path -from os.path import join as pjoin +from os.path import join as pjoin, dirname import glob import tarfile +from ConfigParser import ConfigParser +import sys +if os.name == 'nt' and not sys.platform == 'cygwin': + raise ValueError("You should use cygwin python on windows for now !") + # Configuration (this should be put in a config file at some point) LAPACK_SRC = pjoin('src', 'lapack-lite-3.1.1') LAPACK_LIB = pjoin(LAPACK_SRC, 'lapack_MINGW32.a') ATLAS_SRC = pjoin('src', 'atlas-3.8.2') ATLAS_BUILDDIR = os.path.join(ATLAS_SRC, "MyObj") -ARCH = "SSE2-P4" -ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH -FC = 'g77' # Use INT_ETIME for lapack if building with gfortran #TIMER = 'INT_ETIME' -LAPACK_F77_FLAGS = '' def build_atlas_tarball(): print "====== Building ATLAS tarbal ======" @@ -61,9 +62,64 @@ clean_atlas() clean_lapack() +TARGETS = {'atlas' : [configure_atlas, build_atlas, build_atlas_tarball], + 'lapack' : build_lapack} + +class Config(object): + def __init__(self): + self.arch = None + self.cpuclass = 'i386' + self.freq = 0 + self.pw = 32 + self.targets = ['blas', 'lapack'] + self.lapack_flags = "" + self.f77 = 'g77' + + def __repr__(self): + r = ["Cpu Configurations: "] + r += ['\tArch: %s' % self.arch] + r += ['\tCpu Class: %s' % self.cpuclass] + r += ['\tFreq: %d MHz' % self.freq] + r += ['\tPointer width: %d bits' % self.pw] + r += ["Targets to build: %s" % str(self.targets)] + return "\n".join(r) + +def read_config(file): + cfgp = ConfigParser() + f = cfgp.read(file) + if len(f) < 1: + raise IOError("file %s not found" % file) + + cfg = Config() + if cfgp.has_section('CPU'): + if cfgp.has_option('CPU', 'ARCH'): + cfg.arch = cfgp.get('CPU', 'ARCH') + if cfgp.has_option('CPU', 'CLASS'): + cfg.cpuclass = cfgp.get('CPU', 'CLASS') + if cfgp.has_option('CPU', 'MHZ'): + cfg.freq = cfgp.getint('CPU', 'MHZ') + if cfgp.has_section('BUILD_OPTIONS'): + if cfgp.has_option('BUILD_OPTIONS', 'TARGETS'): + cfg.targets = cfgp.get('BUILD_OPTIONS', 'TARGETS').split(',') + if cfgp.has_option('BUILD_OPTIONS', 'F77'): + cfg.f77 = cfgp.get('BUILD_OPTIONS', 'F77') + if cfgp.has_option('BUILD_OPTIONS', 'LAPACK_F77FLAGS'): + cfg.lapack_flags = " ".join(cfgp.get('BUILD_OPTIONS', 'LAPACK_F77FLAGS').split(',')) + + return cfg + if __name__ == '__main__': + try: + cfg = read_config(pjoin(dirname(__file__), 'site.cfg')) + except IOError: + print "Using default config (site.cfg not found)" + cfg = Config() + + ARCH = cfg.arch + FC = cfg.f77 + LAPACK_F77_FLAGS = cfg.lapack_flags + ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH + clean() - build_lapack() - configure_atlas() - build_atlas() - build_atlas_tarball() + #for i in cfg.targets: + # TARGETS[i]() Added: vendor/tools/sse2.cfg =================================================================== --- vendor/tools/sse2.cfg 2008-07-25 18:35:17 UTC (rev 5526) +++ vendor/tools/sse2.cfg 2008-07-26 05:00:39 UTC (rev 5527) @@ -0,0 +1,10 @@ +[CPU] +ARCH = SSE2 +CLASS = P4 +MHZ = 3200 +# Pointer Width in bits (Not well detected by ATLAS on Windows at least) +PW = 32 +[BUILD_OPTIONS] +TARGETS = lapack +#LAPACK_F77FLAGS = -O3,-funroll-loops +F77 = g77 From numpy-svn at scipy.org Sat Jul 26 01:02:46 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:02:46 -0500 (CDT) Subject: [Numpy-svn] r5528 - vendor/tools Message-ID: <20080726050246.31DEB39C721@scipy.org> Author: cdavid Date: 2008-07-26 00:02:41 -0500 (Sat, 26 Jul 2008) New Revision: 5528 Modified: vendor/tools/build.py vendor/tools/sse2.cfg Log: Fix sse2.cfg. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-26 05:00:39 UTC (rev 5527) +++ vendor/tools/build.py 2008-07-26 05:02:41 UTC (rev 5528) @@ -121,5 +121,5 @@ ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH clean() - #for i in cfg.targets: - # TARGETS[i]() + for i in cfg.targets: + TARGETS[i]() Modified: vendor/tools/sse2.cfg =================================================================== --- vendor/tools/sse2.cfg 2008-07-26 05:00:39 UTC (rev 5527) +++ vendor/tools/sse2.cfg 2008-07-26 05:02:41 UTC (rev 5528) @@ -5,6 +5,6 @@ # Pointer Width in bits (Not well detected by ATLAS on Windows at least) PW = 32 [BUILD_OPTIONS] -TARGETS = lapack -#LAPACK_F77FLAGS = -O3,-funroll-loops +TARGETS = lapack,atlas +LAPACK_F77FLAGS = -O3,-funroll-loops F77 = g77 From numpy-svn at scipy.org Sat Jul 26 01:03:07 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:03:07 -0500 (CDT) Subject: [Numpy-svn] r5529 - vendor/tools Message-ID: <20080726050307.CC62039C509@scipy.org> Author: cdavid Date: 2008-07-26 00:03:03 -0500 (Sat, 26 Jul 2008) New Revision: 5529 Added: vendor/tools/sse3.cfg Log: Add sse3 config. Added: vendor/tools/sse3.cfg =================================================================== --- vendor/tools/sse3.cfg 2008-07-26 05:02:41 UTC (rev 5528) +++ vendor/tools/sse3.cfg 2008-07-26 05:03:03 UTC (rev 5529) @@ -0,0 +1,10 @@ +[CPU] +ARCH = SSE3 +CLASS = Core2Duo +MHZ = 2400 +# Pointer Width in bits (Not well detected by ATLAS on Windows at least) +PW = 32 +[BUILD_OPTIONS] +TARGETS = lapack,atlas +LAPACK_F77FLAGS = -O3,-funroll-loops +F77 = g77 From numpy-svn at scipy.org Sat Jul 26 01:07:08 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:07:08 -0500 (CDT) Subject: [Numpy-svn] r5530 - vendor/tools Message-ID: <20080726050708.89CEC39C509@scipy.org> Author: cdavid Date: 2008-07-26 00:07:04 -0500 (Sat, 26 Jul 2008) New Revision: 5530 Modified: vendor/tools/build.py Log: Add blas build (for def configuration). Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-26 05:03:03 UTC (rev 5529) +++ vendor/tools/build.py 2008-07-26 05:07:04 UTC (rev 5530) @@ -48,11 +48,21 @@ p = Popen(["make", "lapacklib", "FORTRAN=%s" % FC, "LOADER=%s" % FC, "OPTS=%s" % LAPACK_F77_FLAGS], cwd = LAPACK_SRC) os.waitpid(p.pid, 0) +def build_blas(): + print "====== Build BLAS ======" + p = Popen(["make", "blaslib", "FORTRAN=%s" % FC, "LOADER=%s" % FC, "OPTS=%s" % LAPACK_F77_FLAGS], cwd = LAPACK_SRC) + os.waitpid(p.pid, 0) + def clean_lapack(): print "====== Clean LAPACK ======" p = Popen(['make', 'cleanlib'], cwd = LAPACK_SRC) os.waitpid(p.pid, 0) +def clean_blas(): + print "====== Clean BLAS ======" + p = Popen(['make', 'clean'], cwd = LAPACK_SRC) + os.waitpid(p.pid, 0) + def clean_atlas(): print "====== Clean ATLAS ======" if os.path.exists(ATLAS_BUILDDIR): @@ -63,7 +73,8 @@ clean_lapack() TARGETS = {'atlas' : [configure_atlas, build_atlas, build_atlas_tarball], - 'lapack' : build_lapack} + 'lapack' : build_lapack, + 'blas' : build_blas} class Config(object): def __init__(self): From numpy-svn at scipy.org Sat Jul 26 01:16:17 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:16:17 -0500 (CDT) Subject: [Numpy-svn] r5531 - vendor/tools Message-ID: <20080726051617.9918E39C8F4@scipy.org> Author: cdavid Date: 2008-07-26 00:16:14 -0500 (Sat, 26 Jul 2008) New Revision: 5531 Modified: vendor/tools/build.py Log: Take the config file as an argument. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-26 05:07:04 UTC (rev 5530) +++ vendor/tools/build.py 2008-07-26 05:16:14 UTC (rev 5531) @@ -78,7 +78,7 @@ class Config(object): def __init__(self): - self.arch = None + self.arch = 'NOSSE' self.cpuclass = 'i386' self.freq = 0 self.pw = 32 @@ -120,11 +120,11 @@ return cfg if __name__ == '__main__': - try: - cfg = read_config(pjoin(dirname(__file__), 'site.cfg')) - except IOError: - print "Using default config (site.cfg not found)" + argc = len(sys.argv) + if argc < 2: cfg = Config() + else: + cfg = read_config(sys.argv[1]) ARCH = cfg.arch FC = cfg.f77 From numpy-svn at scipy.org Sat Jul 26 01:17:33 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:17:33 -0500 (CDT) Subject: [Numpy-svn] r5532 - vendor/tools Message-ID: <20080726051733.A944939C8F4@scipy.org> Author: cdavid Date: 2008-07-26 00:17:29 -0500 (Sat, 26 Jul 2008) New Revision: 5532 Added: vendor/tools/nosse.cfg Log: Add a nosse config. Added: vendor/tools/nosse.cfg =================================================================== --- vendor/tools/nosse.cfg 2008-07-26 05:16:14 UTC (rev 5531) +++ vendor/tools/nosse.cfg 2008-07-26 05:17:29 UTC (rev 5532) @@ -0,0 +1,10 @@ +[CPU] +ARCH = NOSSE +CLASS = i386 +MHZ = 0 +# Pointer Width in bits (Not well detected by ATLAS on Windows at least) +PW = 32 +[BUILD_OPTIONS] +TARGETS = blas,lapack +LAPACK_F77FLAGS = -O3,-funroll-loops +F77 = g77 From numpy-svn at scipy.org Sat Jul 26 01:19:39 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:19:39 -0500 (CDT) Subject: [Numpy-svn] r5533 - vendor/tools Message-ID: <20080726051939.651D539C8F4@scipy.org> Author: cdavid Date: 2008-07-26 00:19:35 -0500 (Sat, 26 Jul 2008) New Revision: 5533 Modified: vendor/tools/build.py Log: Fix handling of list of targets. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-26 05:17:29 UTC (rev 5532) +++ vendor/tools/build.py 2008-07-26 05:19:35 UTC (rev 5533) @@ -73,8 +73,8 @@ clean_lapack() TARGETS = {'atlas' : [configure_atlas, build_atlas, build_atlas_tarball], - 'lapack' : build_lapack, - 'blas' : build_blas} + 'lapack' : [build_lapack], + 'blas' : [build_blas]} class Config(object): def __init__(self): @@ -132,5 +132,7 @@ ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH clean() - for i in cfg.targets: - TARGETS[i]() + for t in cfg.targets: + target = TARGETS[t] + for action in target: + action() From numpy-svn at scipy.org Sat Jul 26 01:32:54 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:32:54 -0500 (CDT) Subject: [Numpy-svn] r5534 - vendor/tools Message-ID: <20080726053254.EF40939C5ED@scipy.org> Author: cdavid Date: 2008-07-26 00:32:51 -0500 (Sat, 26 Jul 2008) New Revision: 5534 Modified: vendor/tools/build.py Log: Set MHz and PW when configuring ATLAS. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-26 05:19:35 UTC (rev 5533) +++ vendor/tools/build.py 2008-07-26 05:32:51 UTC (rev 5534) @@ -40,7 +40,7 @@ if os.path.exists(ATLAS_BUILDDIR): shutil.rmtree(ATLAS_BUILDDIR) os.makedirs(ATLAS_BUILDDIR) - p = Popen(['../configure', '--with-netlib-lapack=%s' % LAPACK_LIB, '-C', 'if', FC], cwd = ATLAS_BUILDDIR) + p = Popen(['../configure', '--with-netlib-lapack=%s' % LAPACK_LIB, '-C', 'if', FC, "-b %d" % ATLAS_PW, "-m %d" ATLAS_MHZ], cwd = ATLAS_BUILDDIR) os.waitpid(p.pid, 0) def build_lapack(): @@ -101,7 +101,7 @@ if len(f) < 1: raise IOError("file %s not found" % file) - cfg = Config() + cfg = Config() if cfgp.has_section('CPU'): if cfgp.has_option('CPU', 'ARCH'): cfg.arch = cfgp.get('CPU', 'ARCH') @@ -130,6 +130,8 @@ FC = cfg.f77 LAPACK_F77_FLAGS = cfg.lapack_flags ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH + ATLAS_PW = cfg.pw + ATLAS_MHZ = cfg.freq clean() for t in cfg.targets: From numpy-svn at scipy.org Sat Jul 26 01:34:16 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:34:16 -0500 (CDT) Subject: [Numpy-svn] r5535 - vendor/tools Message-ID: <20080726053416.7A48C39C5ED@scipy.org> Author: cdavid Date: 2008-07-26 00:34:13 -0500 (Sat, 26 Jul 2008) New Revision: 5535 Modified: vendor/tools/sse3.cfg Log: Fix freq to arno's CPU. Modified: vendor/tools/sse3.cfg =================================================================== --- vendor/tools/sse3.cfg 2008-07-26 05:32:51 UTC (rev 5534) +++ vendor/tools/sse3.cfg 2008-07-26 05:34:13 UTC (rev 5535) @@ -1,7 +1,7 @@ [CPU] ARCH = SSE3 CLASS = Core2Duo -MHZ = 2400 +MHZ = 3000 # Pointer Width in bits (Not well detected by ATLAS on Windows at least) PW = 32 [BUILD_OPTIONS] From numpy-svn at scipy.org Sat Jul 26 01:39:43 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:39:43 -0500 (CDT) Subject: [Numpy-svn] r5536 - in vendor: . tools Message-ID: <20080726053943.0A0A839C5ED@scipy.org> Author: cdavid Date: 2008-07-26 00:39:35 -0500 (Sat, 26 Jul 2008) New Revision: 5536 Added: vendor/binaries/ Modified: vendor/tools/build.py Log: Fix typo. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-26 05:34:13 UTC (rev 5535) +++ vendor/tools/build.py 2008-07-26 05:39:35 UTC (rev 5536) @@ -40,7 +40,7 @@ if os.path.exists(ATLAS_BUILDDIR): shutil.rmtree(ATLAS_BUILDDIR) os.makedirs(ATLAS_BUILDDIR) - p = Popen(['../configure', '--with-netlib-lapack=%s' % LAPACK_LIB, '-C', 'if', FC, "-b %d" % ATLAS_PW, "-m %d" ATLAS_MHZ], cwd = ATLAS_BUILDDIR) + p = Popen(['../configure', '--with-netlib-lapack=%s' % LAPACK_LIB, '-C', 'if', FC, "-b %d" % ATLAS_PW, "-m %d" % ATLAS_MHZ], cwd = ATLAS_BUILDDIR) os.waitpid(p.pid, 0) def build_lapack(): From numpy-svn at scipy.org Sat Jul 26 01:48:21 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:48:21 -0500 (CDT) Subject: [Numpy-svn] r5537 - vendor/tools Message-ID: <20080726054821.DEF6C39C5ED@scipy.org> Author: cdavid Date: 2008-07-26 00:48:08 -0500 (Sat, 26 Jul 2008) New Revision: 5537 Modified: vendor/tools/build.py Log: Fix configuration step of ATLAS. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-26 05:39:35 UTC (rev 5536) +++ vendor/tools/build.py 2008-07-26 05:48:08 UTC (rev 5537) @@ -40,7 +40,7 @@ if os.path.exists(ATLAS_BUILDDIR): shutil.rmtree(ATLAS_BUILDDIR) os.makedirs(ATLAS_BUILDDIR) - p = Popen(['../configure', '--with-netlib-lapack=%s' % LAPACK_LIB, '-C', 'if', FC, "-b %d" % ATLAS_PW, "-m %d" % ATLAS_MHZ], cwd = ATLAS_BUILDDIR) + p = Popen(['../configure', '-C', 'if', FC, "-b", str(ATLAS_PW), "-m", str(ATLAS_MHZ), '--with-netlib-lapack=%s' % LAPACK_LIB], cwd = ATLAS_BUILDDIR) os.waitpid(p.pid, 0) def build_lapack(): From numpy-svn at scipy.org Sat Jul 26 01:58:43 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 00:58:43 -0500 (CDT) Subject: [Numpy-svn] r5538 - vendor Message-ID: <20080726055843.B66B839C5ED@scipy.org> Author: cdavid Date: 2008-07-26 00:58:39 -0500 (Sat, 26 Jul 2008) New Revision: 5538 Added: vendor/README.txt Log: Add basic README.txt for instructions on building blas/lapack installer. Added: vendor/README.txt =================================================================== --- vendor/README.txt 2008-07-26 05:48:08 UTC (rev 5537) +++ vendor/README.txt 2008-07-26 05:58:39 UTC (rev 5538) @@ -0,0 +1,39 @@ +This directory contains the sources and tools necessary for building mandatory +dependencies of numpy/lapack, with a special focus on Windows. + +The directory is organized as followed: + * src: sources of the dependencies + * tools: various scripts to build the binaries of the dependencies + +In Particular, the tools directory contains: + * a build.py script to build blas/lapack on Win32 from a configuration + file. + * basic.nsi: a NSIS script to build an installer for blas/lapack under + different architectures. + +The build.py tool +================= + +dependencies: +------------- + +cygwin with make, gcc, g77 and python + +How to use: +----------- + +python tools/build.py tools/sse3.cfg + +Will build a blas/lapack using configuration in tools/sse3.cfg. In particular, +it contains informations on whether to build atlas or not, which fortran +compiler to use, etc... + +The basic.nsi script +==================== + +You need NSIS to use it: http://nsis.sourceforge.net/Main_Page You also need a +small plugin cpu_caps, to tell NSIS wether the running CPU supports SSE2, +SSE3, etc... + +It will look for binaries in the binaries directory: one directory per arch. A +subdir mingw32 is used for differentiatin with the not-yet supported Win64. From numpy-svn at scipy.org Sat Jul 26 02:09:32 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 01:09:32 -0500 (CDT) Subject: [Numpy-svn] r5539 - vendor/tools Message-ID: <20080726060932.75C3F39C5ED@scipy.org> Author: cdavid Date: 2008-07-26 01:09:28 -0500 (Sat, 26 Jul 2008) New Revision: 5539 Modified: vendor/tools/build.py Log: Set absolute path for lapack for ATLAS configuration. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-26 05:58:39 UTC (rev 5538) +++ vendor/tools/build.py 2008-07-26 06:09:28 UTC (rev 5539) @@ -3,7 +3,7 @@ from subprocess import Popen import shutil import os.path -from os.path import join as pjoin, dirname +from os.path import join as pjoin, dirname, abspath import glob import tarfile from ConfigParser import ConfigParser @@ -13,10 +13,11 @@ raise ValueError("You should use cygwin python on windows for now !") # Configuration (this should be put in a config file at some point) +# All path are relative to top directory (vendor) LAPACK_SRC = pjoin('src', 'lapack-lite-3.1.1') -LAPACK_LIB = pjoin(LAPACK_SRC, 'lapack_MINGW32.a') +LAPACK_LIB = abspath(pjoin(LAPACK_SRC, 'lapack_MINGW32.a')) ATLAS_SRC = pjoin('src', 'atlas-3.8.2') -ATLAS_BUILDDIR = os.path.join(ATLAS_SRC, "MyObj") +ATLAS_BUILDDIR = pjoin(ATLAS_SRC, "MyObj") # Use INT_ETIME for lapack if building with gfortran #TIMER = 'INT_ETIME' From numpy-svn at scipy.org Sat Jul 26 02:09:59 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 01:09:59 -0500 (CDT) Subject: [Numpy-svn] r5540 - vendor Message-ID: <20080726060959.C7F6E39C5ED@scipy.org> Author: cdavid Date: 2008-07-26 01:09:54 -0500 (Sat, 26 Jul 2008) New Revision: 5540 Modified: vendor/README.txt Log: Add note on using nsis on Linux. Modified: vendor/README.txt =================================================================== --- vendor/README.txt 2008-07-26 06:09:28 UTC (rev 5539) +++ vendor/README.txt 2008-07-26 06:09:54 UTC (rev 5540) @@ -37,3 +37,12 @@ It will look for binaries in the binaries directory: one directory per arch. A subdir mingw32 is used for differentiatin with the not-yet supported Win64. + +Note +---- + +Although the binaries themselves have to be built on windows (ATLAS is not +cross-compilable AFAIK), the installer itself can be built under linux. Debian +contains nsis ported on Linux: + +makensis tools/basic.nsis From numpy-svn at scipy.org Sat Jul 26 02:13:45 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 01:13:45 -0500 (CDT) Subject: [Numpy-svn] r5541 - vendor Message-ID: <20080726061345.1FBDF39C8FD@scipy.org> Author: cdavid Date: 2008-07-26 01:13:42 -0500 (Sat, 26 Jul 2008) New Revision: 5541 Modified: vendor/README.txt Log: Add a caveats section, to tell how to kill atlas build. Modified: vendor/README.txt =================================================================== --- vendor/README.txt 2008-07-26 06:09:54 UTC (rev 5540) +++ vendor/README.txt 2008-07-26 06:13:42 UTC (rev 5541) @@ -46,3 +46,16 @@ contains nsis ported on Linux: makensis tools/basic.nsis + +CAVEATS +======= + +The build.py script is really basic. It does not handle failure well, and it +may be difficult to interrupt (windows indiosyncraties wrt process management +and lack of signals do not help; add cygwin on the top of it to make things +more complex). + +The only solution I can see would be to use ctypes to use windows specific +ProcessTerminate. To stop atlas build is not easy either: even from cygwin +shell, you cannot stop it easily. The easiest way I am aware of is to kill the +AtlasTee.exe process (from cygwin or from the windows TaksManager). From numpy-svn at scipy.org Sat Jul 26 02:29:13 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 01:29:13 -0500 (CDT) Subject: [Numpy-svn] r5542 - in trunk/tools/win32build: . cpucaps Message-ID: <20080726062913.1AC2439C5ED@scipy.org> Author: cdavid Date: 2008-07-26 01:29:08 -0500 (Sat, 26 Jul 2008) New Revision: 5542 Added: trunk/tools/win32build/cpucaps/ trunk/tools/win32build/cpucaps/SConstruct trunk/tools/win32build/cpucaps/cpucaps_main.c trunk/tools/win32build/cpucaps/cpucaps_main.h Log: Add cpu_caps nsis plugin sources (to detect SSE in nsis scripts). Added: trunk/tools/win32build/cpucaps/SConstruct =================================================================== --- trunk/tools/win32build/cpucaps/SConstruct 2008-07-26 06:13:42 UTC (rev 5541) +++ trunk/tools/win32build/cpucaps/SConstruct 2008-07-26 06:29:08 UTC (rev 5542) @@ -0,0 +1,8 @@ +env = Environment(tools = ['mingw']) + +env.Append(CPPPATH = ['../cpuid']) +env.Append(CFLAGS = ['-W', '-Wall']) +cpuplug = env.SharedLibrary('cpucaps', source = ['cpucaps_main.c', '../cpuid/cpuid.c']) + +cpuplug_install = env.InstallAs('C:\Program Files\NSIS\Plugins\CpuCaps.dll', cpuplug[0]) +env.Alias('install', cpuplug_install) Added: trunk/tools/win32build/cpucaps/cpucaps_main.c =================================================================== --- trunk/tools/win32build/cpucaps/cpucaps_main.c 2008-07-26 06:13:42 UTC (rev 5541) +++ trunk/tools/win32build/cpucaps/cpucaps_main.c 2008-07-26 06:29:08 UTC (rev 5542) @@ -0,0 +1,108 @@ +#include + +#include +#include "cpucaps_main.h" + +#include "cpuid.h" + +HINSTANCE g_hInstance; + +HWND g_hwndParent; + +#define CPUID_FAILED "Unknown" + +/* + * if val is true, str is the "Y" string, otherwise the "N" string + */ +static int _set_bool_str(int val, char* str) +{ + if (val) { + str[0] = 'Y'; + } else { + str[0] = 'N'; + } + str[1] = '\0'; + + return 0; +} + +void __declspec(dllexport) hasSSE3(HWND hwndParent, int string_size, + char *variables, stack_t **stacktop, + extra_parameters *extra) +{ + cpu_caps_t *cpu; + char has_sse3[2]; + + //g_hwndParent=hwndParent; + + EXDLL_INIT(); + + + // note if you want parameters from the stack, pop them off in order. + // i.e. if you are called via exdll::myFunction file.dat poop.dat + // calling popstring() the first time would give you file.dat, + // and the second time would give you poop.dat. + // you should empty the stack of your parameters, and ONLY your + // parameters. + + // do your stuff here + cpu = malloc(sizeof(*cpu)); + if (cpu == NULL) { + fprintf(stderr, "malloc call failed\n"); + _set_bool_str(0, has_sse3); + goto push_vars; + } + cpuid_get_caps(cpu); + _set_bool_str(cpu->has_sse3, has_sse3); + + +push_vars: + pushstring(has_sse3); + + return ; +} + + +void __declspec(dllexport) hasSSE2(HWND hwndParent, int string_size, + char *variables, stack_t **stacktop, + extra_parameters *extra) +{ + cpu_caps_t *cpu; + char has_sse2[2]; + + //g_hwndParent=hwndParent; + + EXDLL_INIT(); + + + // note if you want parameters from the stack, pop them off in order. + // i.e. if you are called via exdll::myFunction file.dat poop.dat + // calling popstring() the first time would give you file.dat, + // and the second time would give you poop.dat. + // you should empty the stack of your parameters, and ONLY your + // parameters. + + // do your stuff here + cpu = malloc(sizeof(*cpu)); + if (cpu == NULL) { + fprintf(stderr, "malloc call failed\n"); + _set_bool_str(0, has_sse2); + goto push_vars; + } + cpuid_get_caps(cpu); + _set_bool_str(cpu->has_sse2, has_sse2); + + +push_vars: + pushstring(has_sse2); + + return ; +} + + + +BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) +{ + g_hInstance=hInst; + return TRUE; +} Added: trunk/tools/win32build/cpucaps/cpucaps_main.h =================================================================== --- trunk/tools/win32build/cpucaps/cpucaps_main.h 2008-07-26 06:13:42 UTC (rev 5541) +++ trunk/tools/win32build/cpucaps/cpucaps_main.h 2008-07-26 06:29:08 UTC (rev 5542) @@ -0,0 +1,128 @@ +#ifndef _EXDLL_H_ +#define _EXDLL_H_ + +#include + +#if defined(__GNUC__) +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif + +// only include this file from one place in your DLL. +// (it is all static, if you use it in two places it will fail) + +#define EXDLL_INIT() { \ + g_stringsize=string_size; \ + g_stacktop=stacktop; \ + g_variables=variables; } + +// For page showing plug-ins +#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8) +#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd) +#define NOTIFY_BYE_BYE 'x' + +typedef struct _stack_t { + struct _stack_t *next; + char text[1]; // this should be the length of string_size +} stack_t; + + +static unsigned int g_stringsize; +static stack_t **g_stacktop; +static char *g_variables; + +static int __stdcall popstring(char *str) UNUSED; // 0 on success, 1 on empty stack +static void __stdcall pushstring(const char *str) UNUSED; +static char * __stdcall getuservariable(const int varnum) UNUSED; +static void __stdcall setuservariable(const int varnum, const char *var) UNUSED; + +enum +{ +INST_0, // $0 +INST_1, // $1 +INST_2, // $2 +INST_3, // $3 +INST_4, // $4 +INST_5, // $5 +INST_6, // $6 +INST_7, // $7 +INST_8, // $8 +INST_9, // $9 +INST_R0, // $R0 +INST_R1, // $R1 +INST_R2, // $R2 +INST_R3, // $R3 +INST_R4, // $R4 +INST_R5, // $R5 +INST_R6, // $R6 +INST_R7, // $R7 +INST_R8, // $R8 +INST_R9, // $R9 +INST_CMDLINE, // $CMDLINE +INST_INSTDIR, // $INSTDIR +INST_OUTDIR, // $OUTDIR +INST_EXEDIR, // $EXEDIR +INST_LANG, // $LANGUAGE +__INST_LAST +}; + +typedef struct { + int autoclose; + int all_user_var; + int exec_error; + int abort; + int exec_reboot; + int reboot_called; + int XXX_cur_insttype; // deprecated + int XXX_insttype_changed; // deprecated + int silent; + int instdir_error; + int rtl; + int errlvl; + int alter_reg_view; +} exec_flags_type; + +typedef struct { + exec_flags_type *exec_flags; + int (__stdcall *ExecuteCodeSegment)(int, HWND); + void (__stdcall *validate_filename)(char *); +} extra_parameters; + +// utility functions (not required but often useful) +static int __stdcall popstring(char *str) +{ + stack_t *th; + if (!g_stacktop || !*g_stacktop) return 1; + th=(*g_stacktop); + lstrcpyA(str,th->text); + *g_stacktop = th->next; + GlobalFree((HGLOBAL)th); + return 0; +} + +static void __stdcall pushstring(const char *str) +{ + stack_t *th; + if (!g_stacktop) return; + th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize); + lstrcpynA(th->text,str,g_stringsize); + th->next=*g_stacktop; + *g_stacktop=th; +} + +static char * __stdcall getuservariable(const int varnum) +{ + if (varnum < 0 || varnum >= __INST_LAST) return NULL; + return g_variables+varnum*g_stringsize; +} + +static void __stdcall setuservariable(const int varnum, const char *var) +{ + if (var != NULL && varnum >= 0 && varnum < __INST_LAST) + lstrcpyA(g_variables + varnum*g_stringsize, var); +} + + + +#endif//_EXDLL_H_ From numpy-svn at scipy.org Sat Jul 26 03:57:02 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sat, 26 Jul 2008 02:57:02 -0500 (CDT) Subject: [Numpy-svn] r5543 - vendor/tools Message-ID: <20080726075702.2B1D139C6FC@scipy.org> Author: cdavid Date: 2008-07-26 02:56:58 -0500 (Sat, 26 Jul 2008) New Revision: 5543 Added: vendor/tools/basic.nsi Log: Add a script for a basic mingw32 stats libs installer. Added: vendor/tools/basic.nsi =================================================================== --- vendor/tools/basic.nsi 2008-07-26 06:29:08 UTC (rev 5542) +++ vendor/tools/basic.nsi 2008-07-26 07:56:58 UTC (rev 5543) @@ -0,0 +1,232 @@ +;=========================================================================== +; This script will build an installer with only mingw32 .a static libraries +; See superpack.nsi for a complete installer with import libraries and dll. +;=========================================================================== + +!define PRODUCT_NAME "BlasLapack superpack" + +;-------------------------------- +;Extra headers necessary + +!include 'MUI.nsh' +!include 'Sections.nsh' +!include 'LogicLib.nsh' + +SetCompress off ; Useful to disable compression under development + +;-------------------------------- +;General + +;Name and file +Name "${PRODUCT_NAME}" +OutFile "setup.exe" + +;Default installation folder +InstallDir "$PROGRAMFILES\${PRODUCT_NAME}" + +;Get installation folder from registry if available +InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" "" + +;-------------------------------- +;Interface Settings + +!define MUI_ABORTWARNING +#!addplugindir "/home/david/local/share/nsis/plugins" + +;-------------------------------- +;Pages + +;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +; !insertmacro MUI_PAGE_FINISH_TEXT "Installation done ! DO NOT FORGET TO PUT THE INSTALLED DLL SOMEWHERE WHERE THEY CAN BE FOUND BY WINDOWS !" + +;-------------------------------- +;Languages + +!insertmacro MUI_LANGUAGE "English" + +;-------------------------- +; Types of installation +; - default: install most optimized available, mingw only (toward people who just want thing to work) +; - custom: choose whatever you want +; - install everything +InstType "Typical" +InstType "Full" + +;-------------------------------- +;Component Sections + +Var HasSSE2 +Var HasSSE3 +Var CPUSSE + +SubSection "Generic BLAS" BLAS + Section "Mingw archives" BLAS_MINGW + SetOutPath "$INSTDIR\Generic\mingw32" + File "binaries\nosse\mingw32\libblas.a" + SectionEnd +SubSectionEnd + +SubSection "Generic LAPACK" LAPACK + Section "Mingw archives" LAPACK_MINGW + SetOutPath "$INSTDIR\Generic\mingw32" + File "binaries\nosse\mingw32\liblapack.a" + SectionEnd +SubSectionEnd + +SubSection "ATLAS" ATLAS + SubSection "SSE2" ATLAS_SSE2 + Section "Mingw archives" ATLAS_SSE2_MINGW + SetOutPath "$INSTDIR\ATLAS\sse2\mingw32" + File "binaries\sse2\mingw32\lib*.a" + SectionEnd + SubSectionEnd + + SubSection "SSE3" ATLAS_SSE3 + Section "Mingw archives" ATLAS_SSE3_MINGW + SetOutPath "$INSTDIR\ATLAS\sse3\mingw32" + File "binaries\sse3\mingw32\lib*.a" + SectionEnd + SubSectionEnd +SubSectionEnd + +Section -Post + ;Create uninstaller + WriteUninstaller "$INSTDIR\Uninstall.exe" +SectionEnd + +Section -Dummy DUMMY +SectionEnd + +Function .onInit + ; Detect CPU target capabilities for ATLAS + StrCpy $CPUSSE "0" + CpuCaps::hasSSE3 + Pop $0 + StrCpy $HasSSE3 $0 + CpuCaps::hasSSE2 + Pop $0 + StrCpy $HasSSE2 $0 + + ; Take care about the order ! + + ; SSE 2 + StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 + include_sse2: + DetailPrint '"Target CPU handles SSE2"' + StrCpy $CPUSSE "2" + goto done_sse2 + no_include_sse2: + DetailPrint '"Target CPU doe NOT handle SSE2"' + goto done_sse2 + done_sse2: + + ; SSE 3 + StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 + include_sse3: + DetailPrint '"Target CPU handles SSE3"' + StrCpy $CPUSSE "3" + goto done_sse3 + no_include_sse3: + DetailPrint '"Target CPU doe NOT handle SSE3"' + goto done_sse3 + done_sse3: + + ${Switch} $CPUSSE + ${Case} "3" + DetailPrint '"Install SSE 3"' + !insertmacro SetSectionInInstType "${ATLAS_SSE3_MINGW}" "1" + ${Break} + ${Case} "2" + DetailPrint '"Install SSE 2"' + !insertmacro SetSectionInInstType "${ATLAS_SSE2_MINGW}" "1" + ${Break} + ${Default} + DetailPrint '"Install NO SSE"' + !insertmacro SetSectionInInstType "${BLAS_MINGW}" "1" + !insertmacro SetSectionInInstType "${LAPACK_MINGW}" "1" + ${Break} + ${EndSwitch} + + !insertmacro SetSectionInInstType "${BLAS_MINGW}" "2" + + !insertmacro SetSectionInInstType "${LAPACK_MINGW}" "2" + + !insertmacro SetSectionInInstType "${ATLAS_SSE2_MINGW}" "2" + + !insertmacro SetSectionInInstType "${ATLAS_SSE3_MINGW}" "2" + + SetCurInstType "0" + WriteRegStr HKCU "Software\${PRODUCT_NAME}" "" $INSTDIR +FunctionEnd + +;-------------------------------- +;Descriptions +;Language strings +LangString DESC_BLAS ${LANG_ENGLISH} "This section contains BLAS libraries.\ + Those are generic, non optimized libraries (from netlib)." +LangString DESC_LAPACK ${LANG_ENGLISH} "This section contains LAPACK libraries.\ + Those are generic, non optimized libraries (from netlib)." + +LangString DESC_ATLAS ${LANG_ENGLISH} "This section contains ATLAS libraries.\ + Those are optimized libraries for BLAS and LAPACK." +LangString DESC_ATLAS_SSE2 ${LANG_ENGLISH} "This section contains ATLAS libraries \ + for CPU supporting at least SSE2. " +LangString DESC_ATLAS_SSE3 ${LANG_ENGLISH} "This section contains ATLAS libraries \ + for CPU supporting at least SSE3. " + +LangString DESC_MINGW ${LANG_ENGLISH} "This will install .a libraries: \ + this is what you need if you compile numpy with mingw32 compilers." + +;Assign language strings to sections +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${BLAS} $(DESC_BLAS) + !insertmacro MUI_DESCRIPTION_TEXT ${BLAS_MINGW} $(DESC_MINGW) + + !insertmacro MUI_DESCRIPTION_TEXT ${LAPACK} $(DESC_LAPACK) + !insertmacro MUI_DESCRIPTION_TEXT ${LAPACK_MINGW} $(DESC_MINGW) + + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS} $(DESC_ATLAS) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE2} $(DESC_ATLAS_SSE2) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE2_MINGW} $(DESC_MINGW) + + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE3} $(DESC_ATLAS_SSE3) + !insertmacro MUI_DESCRIPTION_TEXT ${ATLAS_SSE3_MINGW} $(DESC_MINGW) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + +;-------------------------------- +;Uninstaller Section + +Section "Uninstall" + + Delete "$INSTDIR\Uninstall.exe" + + ; XXX: we should track the installed files instead, but I am lazy + + ; Generic libs + Delete "$INSTDIR\generic\mingw32\libblas.a" + Delete "$INSTDIR\generic\mingw32\liblapack.a" + RMDir "$INSTDIR\generic\mingw32" + + RMDir "$INSTDIR\generic\lib" + RMDir "$INSTDIR\generic" + + ; ATLAS SSE2 + Delete "$INSTDIR\sse2\mingw32\*.a" + RMDir "$INSTDIR\sse2\mingw32" + RMDir "$INSTDIR\sse2" + + ; ATLAS SSE2 + Delete "$INSTDIR\sse3\mingw32\*.a" + RMDir "$INSTDIR\sse3\mingw32" + RMDir "$INSTDIR\sse3" + RMDir "$INSTDIR" + + DeleteRegKey /ifempty HKCU "Software\${PRODUCT_NAME}" + +SectionEnd From numpy-svn at scipy.org Sun Jul 27 22:05:07 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 21:05:07 -0500 (CDT) Subject: [Numpy-svn] r5544 - trunk/tools/win32build Message-ID: <20080728020507.8E8BC39C05F@scipy.org> Author: cdavid Date: 2008-07-27 21:05:03 -0500 (Sun, 27 Jul 2008) New Revision: 5544 Modified: trunk/tools/win32build/build.py Log: Use OptionParser for win32 build script. Modified: trunk/tools/win32build/build.py =================================================================== --- trunk/tools/win32build/build.py 2008-07-26 07:56:58 UTC (rev 5543) +++ trunk/tools/win32build/build.py 2008-07-28 02:05:03 UTC (rev 5544) @@ -10,6 +10,7 @@ import subprocess import os import shutil +from os.path import join as pjoin, split as psplit, dirname PYEXECS = {"2.5" : "C:\python25\python.exe", "2.4" : "C:\python24\python2.4.exe"} @@ -94,17 +95,22 @@ name = "numpy-%s.win32-py%s.exe" % (get_numpy_version(), pyver) return name -USAGE = """build.py ARCH PYTHON_VERSION +if __name__ == '__main__': + from optparse import OptionParser + parser = OptionParser() + parser.add_option("-a", "--arch", dest="arch", + help = "Architecture to build (sse2, sse3, nosse, etc...)") + parser.add_option("-p", "--pyver", dest="pyver", + help = "Python version (2.4, 2.5, etc...)") -Example: build.py sse2 2.4.""" + opts, args = parser.parse_args() + arch = opts.arch + pyver = opts.pyver -if __name__ == '__main__': - if len(sys.argv) < 3: - raise ValueError(USAGE) - sys.exit(-1) - - arch = sys.argv[1] - pyver = sys.argv[2] - #build(arch, pyver) - for arch in SITECFG.keys(): - build(arch, pyver) + if not arch: + arch = "nosse" + if not pyver: + pyver = "2.5" + build(arch, pyver) + #for arch in SITECFG.keys(): + # build(arch, pyver) From numpy-svn at scipy.org Sun Jul 27 22:05:44 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 21:05:44 -0500 (CDT) Subject: [Numpy-svn] r5545 - in branches/1.1.x/tools/win32build: . cpuid nsis_scripts Message-ID: <20080728020544.7A93139C05F@scipy.org> Author: cdavid Date: 2008-07-27 21:05:30 -0500 (Sun, 27 Jul 2008) New Revision: 5545 Added: branches/1.1.x/tools/win32build/README.txt branches/1.1.x/tools/win32build/cpuid/ branches/1.1.x/tools/win32build/cpuid/SConstruct branches/1.1.x/tools/win32build/cpuid/cpuid.c branches/1.1.x/tools/win32build/cpuid/cpuid.h branches/1.1.x/tools/win32build/cpuid/test.c branches/1.1.x/tools/win32build/nsis_scripts/ branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi Removed: branches/1.1.x/tools/win32build/cpuid/SConstruct branches/1.1.x/tools/win32build/cpuid/cpuid.c branches/1.1.x/tools/win32build/cpuid/cpuid.h branches/1.1.x/tools/win32build/cpuid/test.c branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi Log: Merge cpuid/nsis_scripts for win32 build. Copied: branches/1.1.x/tools/win32build/README.txt (from rev 5240, trunk/tools/win32build/README.txt) Copied: branches/1.1.x/tools/win32build/cpuid (from rev 5240, trunk/tools/win32build/cpuid) Deleted: branches/1.1.x/tools/win32build/cpuid/SConstruct =================================================================== --- trunk/tools/win32build/cpuid/SConstruct 2008-05-26 11:29:37 UTC (rev 5240) +++ branches/1.1.x/tools/win32build/cpuid/SConstruct 2008-07-28 02:05:30 UTC (rev 5545) @@ -1,5 +0,0 @@ -env = Environment(tools = ['mingw']) - -#libcpuid = env.SharedLibrary('cpuid', source = ['cpuid.c']) -#test = env.Program('test', source = ['test.c'], LIBS = libcpuid, RPATH = ['.']) -test = env.Program('test', source = ['test.c', 'cpuid.c']) Copied: branches/1.1.x/tools/win32build/cpuid/SConstruct (from rev 5240, trunk/tools/win32build/cpuid/SConstruct) Deleted: branches/1.1.x/tools/win32build/cpuid/cpuid.c =================================================================== --- trunk/tools/win32build/cpuid/cpuid.c 2008-05-26 11:29:37 UTC (rev 5240) +++ branches/1.1.x/tools/win32build/cpuid/cpuid.c 2008-07-28 02:05:30 UTC (rev 5545) @@ -1,169 +0,0 @@ -/* - * TODO: - * - test for cpuid availability - * - test for OS support (tricky) - */ - -#include -#include -#include - -#include "cpuid.h" - -#ifndef __GNUC__ -#error "Sorry, this code can only be compiled with gcc for now" -#endif - -/* - * SIMD: SSE 1, 2 and 3, MMX - */ -#define CPUID_FLAG_MMX 1 << 23 /* in edx */ -#define CPUID_FLAG_SSE 1 << 25 /* in edx */ -#define CPUID_FLAG_SSE2 1 << 26 /* in edx */ -#define CPUID_FLAG_SSE3 1 << 0 /* in ecx */ - -/* - * long mode (AMD64 instruction set) - */ -#define CPUID_FLAGS_LONG_MODE 1 << 29 /* in edx */ - -/* - * struct reprensenting the cpuid flags as put in the register - */ -typedef struct { - uint32_t eax; - uint32_t ebx; - uint32_t ecx; - uint32_t edx; -} cpuid_t; - -/* - * Union to read bytes in 32 (intel) bits registers - */ -union _le_reg { - uint8_t ccnt[4]; - uint32_t reg; -} __attribute__ ((packed)); -typedef union _le_reg le_reg_t ; - -/* - * can_cpuid and read_cpuid are the two only functions using asm - */ -static int can_cpuid(void) -{ - int has_cpuid = 0 ; - - /* - * See intel doc on cpuid (pdf) - */ - asm volatile ( - "pushfl \n\t" - "popl %%eax \n\t" - "movl %%eax, %%ecx \n\t" - "xorl $0x200000, %%eax \n\t" - "pushl %%eax \n\t" - "popfl \n\t" - "pushfl \n\t" - "popl %%eax \n\t" - "xorl %%ecx, %%eax \n\t" - "andl $0x200000, %%eax \n\t" - "movl %%eax,%0 \n\t" - :"=m" (has_cpuid) - : /*no input*/ - : "eax","ecx","cc"); - - return (has_cpuid != 0) ; -} - -/* - * func is the "level" of cpuid. See for cpuid.txt - */ -static cpuid_t read_cpuid(unsigned int func) -{ - cpuid_t res; - - /* we save ebx because it is used when compiled by -fPIC */ - asm volatile( - "pushl %%ebx \n\t" /* save %ebx */ - "cpuid \n\t" - "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */ - "popl %%ebx \n\t" /* restore the old %ebx */ - : "=a"(res.eax), "=r"(res.ebx), - "=c"(res.ecx), "=d"(res.edx) - : "a"(func) - : "cc"); - - return res; -} - -static uint32_t get_max_func() -{ - cpuid_t cpuid; - - cpuid = read_cpuid(0); - return cpuid.eax; -} - -/* - * vendor should have at least CPUID_VENDOR_STRING_LEN characters - */ -static int get_vendor_string(cpuid_t cpuid, char vendor[]) -{ - int i; - le_reg_t treg; - - treg.reg = cpuid.ebx; - for (i = 0; i < 4; ++i) { - vendor[i] = treg.ccnt[i]; - } - - treg.reg = cpuid.edx; - for (i = 0; i < 4; ++i) { - vendor[i+4] = treg.ccnt[i]; - } - - treg.reg = cpuid.ecx; - for (i = 0; i < 4; ++i) { - vendor[i+8] = treg.ccnt[i]; - } - vendor[12] = '\0'; - return 0; -} - -int cpuid_get_caps(cpu_caps_t *cpu) -{ - cpuid_t cpuid; - int max; - - memset(cpu, 0, sizeof(*cpu)); - - if (!can_cpuid()) { - return 0; - } - - max = get_max_func(); - - /* Read vendor string */ - cpuid = read_cpuid(0); - get_vendor_string(cpuid, cpu->vendor); - - if (max < 0x00000001) { - return 0; - } - cpuid = read_cpuid(0x00000001); - - /* We can read mmx, sse 1 2 and 3 when cpuid level >= 0x00000001 */ - if (cpuid.edx & CPUID_FLAG_MMX) { - cpu->has_mmx = 1; - } - if (cpuid.edx & CPUID_FLAG_SSE) { - cpu->has_sse = 1; - } - if (cpuid.edx & CPUID_FLAG_SSE2) { - cpu->has_sse2 = 1; - } - if (cpuid.ecx & CPUID_FLAG_SSE3) { - cpu->has_sse3 = 1; - } - return 0; -} Copied: branches/1.1.x/tools/win32build/cpuid/cpuid.c (from rev 5240, trunk/tools/win32build/cpuid/cpuid.c) Deleted: branches/1.1.x/tools/win32build/cpuid/cpuid.h =================================================================== --- trunk/tools/win32build/cpuid/cpuid.h 2008-05-26 11:29:37 UTC (rev 5240) +++ branches/1.1.x/tools/win32build/cpuid/cpuid.h 2008-07-28 02:05:30 UTC (rev 5545) @@ -1,20 +0,0 @@ -#ifndef _GABOU_CPUID_H -#define _GABOU_CPUID_H - -#include - -#define CPUID_VENDOR_STRING_LEN 12 - -struct _cpu_caps { - int has_cpuid; - int has_mmx; - int has_sse; - int has_sse2; - int has_sse3; - char vendor[CPUID_VENDOR_STRING_LEN+1]; -}; -typedef struct _cpu_caps cpu_caps_t; - -int cpuid_get_caps(cpu_caps_t *cpuinfo); - -#endif Copied: branches/1.1.x/tools/win32build/cpuid/cpuid.h (from rev 5240, trunk/tools/win32build/cpuid/cpuid.h) Deleted: branches/1.1.x/tools/win32build/cpuid/test.c =================================================================== --- trunk/tools/win32build/cpuid/test.c 2008-05-26 11:29:37 UTC (rev 5240) +++ branches/1.1.x/tools/win32build/cpuid/test.c 2008-07-28 02:05:30 UTC (rev 5545) @@ -1,44 +0,0 @@ -#include - -#include "cpuid.h" - -int main() -{ - cpu_caps_t *cpuinfo; - - cpuinfo = malloc(sizeof(*cpuinfo)); - - if (cpuinfo == NULL) { - fprintf(stderr, "Error allocating\n"); - } - - cpuid_get_caps(cpuinfo); - printf("This cpu string is %s\n", cpuinfo->vendor); - - if (cpuinfo->has_mmx) { - printf("This cpu has mmx instruction set\n"); - } else { - printf("This cpu does NOT have mmx instruction set\n"); - } - - if (cpuinfo->has_sse) { - printf("This cpu has sse instruction set\n"); - } else { - printf("This cpu does NOT have sse instruction set\n"); - } - - if (cpuinfo->has_sse2) { - printf("This cpu has sse2 instruction set\n"); - } else { - printf("This cpu does NOT have sse2 instruction set\n"); - } - - if (cpuinfo->has_sse3) { - printf("This cpu has sse3 instruction set\n"); - } else { - printf("This cpu does NOT have sse3 instruction set\n"); - } - - free(cpuinfo); - return 0; -} Copied: branches/1.1.x/tools/win32build/cpuid/test.c (from rev 5240, trunk/tools/win32build/cpuid/test.c) Copied: branches/1.1.x/tools/win32build/nsis_scripts (from rev 5240, trunk/tools/win32build/nsis_scripts) Deleted: branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi =================================================================== --- trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi 2008-05-26 11:29:37 UTC (rev 5240) +++ branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi 2008-07-28 02:05:30 UTC (rev 5545) @@ -1,120 +0,0 @@ -;-------------------------------- -;Include Modern UI - -!include "MUI2.nsh" - -;SetCompress off ; Useful to disable compression under development - -;-------------------------------- -;General - -;Name and file -Name "Numpy super installer" -OutFile "numpy-1.1.0-win32-superpack-python2.4.exe" - -;Default installation folder -InstallDir "$TEMP" - -;-------------------------------- -;Interface Settings - -!define MUI_ABORTWARNING - -;-------------------------------- -;Pages - -;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" -;!insertmacro MUI_PAGE_COMPONENTS -;!insertmacro MUI_PAGE_DIRECTORY -;!insertmacro MUI_PAGE_INSTFILES - -;!insertmacro MUI_UNPAGE_CONFIRM -;!insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - -!insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Component Sections - -!include 'Sections.nsh' -!include LogicLib.nsh - -Var HasSSE2 -Var HasSSE3 -Var CPUSSE - -Section "Core" SecCore - - ;SectionIn RO - SetOutPath "$INSTDIR" - - ;Create uninstaller - ;WriteUninstaller "$INSTDIR\Uninstall.exe" - - DetailPrint "Install dir for actual installers is $INSTDIR" - - StrCpy $CPUSSE "0" - CpuCaps::hasSSE2 - Pop $0 - StrCpy $HasSSE2 $0 - - CpuCaps::hasSSE3 - Pop $0 - StrCpy $HasSSE3 $0 - - ; Debug - StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 - include_sse2: - DetailPrint '"Target CPU handles SSE2"' - StrCpy $CPUSSE "2" - goto done_sse2 - no_include_sse2: - DetailPrint '"Target CPU does NOT handle SSE2"' - goto done_sse2 - done_sse2: - - StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 - include_sse3: - DetailPrint '"Target CPU handles SSE3"' - StrCpy $CPUSSE "3" - goto done_sse3 - no_include_sse3: - DetailPrint '"Target CPU does NOT handle SSE3"' - goto done_sse3 - done_sse3: - - ClearErrors - - ; Install files conditionaly on detected cpu - ${Switch} $CPUSSE - ${Case} "3" - DetailPrint '"Install SSE 3"' - File "numpy-1.1.0-sse3.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse3.exe"' - ${Break} - ${Case} "2" - DetailPrint '"Install SSE 2"' - File "numpy-1.1.0-sse2.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse2.exe"' - ${Break} - ${Default} - DetailPrint '"Install NO SSE"' - File "numpy-1.1.0-nosse.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-nosse.exe"' - ${Break} - ${EndSwitch} - - ; Handle errors when executing installers - IfErrors error no_error - - error: - messageBox MB_OK "Executing numpy installer failed" - goto done - no_error: - goto done - done: - -SectionEnd Copied: branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi (from rev 5240, trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi) Deleted: branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi =================================================================== --- trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi 2008-05-26 11:29:37 UTC (rev 5240) +++ branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi 2008-07-28 02:05:30 UTC (rev 5545) @@ -1,120 +0,0 @@ -;-------------------------------- -;Include Modern UI - -!include "MUI2.nsh" - -;SetCompress off ; Useful to disable compression under development - -;-------------------------------- -;General - -;Name and file -Name "Numpy super installer" -OutFile "numpy-1.1.0-win32-superpack-python2.5.exe" - -;Default installation folder -InstallDir "$TEMP" - -;-------------------------------- -;Interface Settings - -!define MUI_ABORTWARNING - -;-------------------------------- -;Pages - -;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" -;!insertmacro MUI_PAGE_COMPONENTS -;!insertmacro MUI_PAGE_DIRECTORY -;!insertmacro MUI_PAGE_INSTFILES - -;!insertmacro MUI_UNPAGE_CONFIRM -;!insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - -!insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Component Sections - -!include 'Sections.nsh' -!include LogicLib.nsh - -Var HasSSE2 -Var HasSSE3 -Var CPUSSE - -Section "Core" SecCore - - ;SectionIn RO - SetOutPath "$INSTDIR" - - ;Create uninstaller - ;WriteUninstaller "$INSTDIR\Uninstall.exe" - - DetailPrint "Install dir for actual installers is $INSTDIR" - - StrCpy $CPUSSE "0" - CpuCaps::hasSSE2 - Pop $0 - StrCpy $HasSSE2 $0 - - CpuCaps::hasSSE3 - Pop $0 - StrCpy $HasSSE3 $0 - - ; Debug - StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 - include_sse2: - DetailPrint '"Target CPU handles SSE2"' - StrCpy $CPUSSE "2" - goto done_sse2 - no_include_sse2: - DetailPrint '"Target CPU does NOT handle SSE2"' - goto done_sse2 - done_sse2: - - StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 - include_sse3: - DetailPrint '"Target CPU handles SSE3"' - StrCpy $CPUSSE "3" - goto done_sse3 - no_include_sse3: - DetailPrint '"Target CPU does NOT handle SSE3"' - goto done_sse3 - done_sse3: - - ClearErrors - - ; Install files conditionaly on detected cpu - ${Switch} $CPUSSE - ${Case} "3" - DetailPrint '"Install SSE 3"' - File "numpy-1.1.0-sse3.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse3.exe"' - ${Break} - ${Case} "2" - DetailPrint '"Install SSE 2"' - File "numpy-1.1.0-sse2.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse2.exe"' - ${Break} - ${Default} - DetailPrint '"Install NO SSE"' - File "numpy-1.1.0-nosse.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-nosse.exe"' - ${Break} - ${EndSwitch} - - ; Handle errors when executing installers - IfErrors error no_error - - error: - messageBox MB_OK "Executing numpy installer failed" - goto done - no_error: - goto done - done: - -SectionEnd Copied: branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi (from rev 5240, trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi) From numpy-svn at scipy.org Sun Jul 27 22:21:24 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 21:21:24 -0500 (CDT) Subject: [Numpy-svn] r5546 - in trunk/tools/win32build: . nsis_scripts Message-ID: <20080728022124.99CBF39C07C@scipy.org> Author: cdavid Date: 2008-07-27 21:21:17 -0500 (Sun, 27 Jul 2008) New Revision: 5546 Added: trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in trunk/tools/win32build/prepare_bootstrap.py Log: Add nsis template, and bootstrap script, to bootstrap win32 binary build. Added: trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in =================================================================== --- trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in 2008-07-28 02:05:30 UTC (rev 5545) +++ trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in 2008-07-28 02:21:17 UTC (rev 5546) @@ -0,0 +1,120 @@ +;-------------------------------- +;Include Modern UI + +!include "MUI2.nsh" + +;SetCompress off ; Useful to disable compression under development + +;-------------------------------- +;General + +;Name and file +Name "Numpy super installer" +OutFile "@NUMPY_INSTALLER_NAME@" + +;Default installation folder +InstallDir "$TEMP" + +;-------------------------------- +;Interface Settings + +!define MUI_ABORTWARNING + +;-------------------------------- +;Pages + +;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" +;!insertmacro MUI_PAGE_COMPONENTS +;!insertmacro MUI_PAGE_DIRECTORY +;!insertmacro MUI_PAGE_INSTFILES + +;!insertmacro MUI_UNPAGE_CONFIRM +;!insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +;Languages + +!insertmacro MUI_LANGUAGE "English" + +;-------------------------------- +;Component Sections + +!include 'Sections.nsh' +!include LogicLib.nsh + +Var HasSSE2 +Var HasSSE3 +Var CPUSSE + +Section "Core" SecCore + + ;SectionIn RO + SetOutPath "$INSTDIR" + + ;Create uninstaller + ;WriteUninstaller "$INSTDIR\Uninstall.exe" + + DetailPrint "Install dir for actual installers is $INSTDIR" + + StrCpy $CPUSSE "0" + CpuCaps::hasSSE2 + Pop $0 + StrCpy $HasSSE2 $0 + + CpuCaps::hasSSE3 + Pop $0 + StrCpy $HasSSE3 $0 + + ; Debug + StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 + include_sse2: + DetailPrint '"Target CPU handles SSE2"' + StrCpy $CPUSSE "2" + goto done_sse2 + no_include_sse2: + DetailPrint '"Target CPU does NOT handle SSE2"' + goto done_sse2 + done_sse2: + + StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 + include_sse3: + DetailPrint '"Target CPU handles SSE3"' + StrCpy $CPUSSE "3" + goto done_sse3 + no_include_sse3: + DetailPrint '"Target CPU does NOT handle SSE3"' + goto done_sse3 + done_sse3: + + ClearErrors + + ; Install files conditionaly on detected cpu + ${Switch} $CPUSSE + ${Case} "3" + DetailPrint '"Install SSE 3"' + File "@SSE3_BINARY@" + ExecWait '"$INSTDIR\@SSE3_BINARY@"' + ${Break} + ${Case} "2" + DetailPrint '"Install SSE 2"' + File "@SSE2_BINARY@" + ExecWait '"$INSTDIR\@SSE2_BINARY@"' + ${Break} + ${Default} + DetailPrint '"Install NO SSE"' + File "@NOSSE_BINARY@" + ExecWait '"$INSTDIR\@NOSSE_BINARY@"' + ${Break} + ${EndSwitch} + + ; Handle errors when executing installers + IfErrors error no_error + + error: + messageBox MB_OK "Executing numpy installer failed" + goto done + no_error: + goto done + done: + +SectionEnd Added: trunk/tools/win32build/prepare_bootstrap.py =================================================================== --- trunk/tools/win32build/prepare_bootstrap.py 2008-07-28 02:05:30 UTC (rev 5545) +++ trunk/tools/win32build/prepare_bootstrap.py 2008-07-28 02:21:17 UTC (rev 5546) @@ -0,0 +1,71 @@ +import os +import subprocess +import shutil +from os.path import join as pjoin, split as psplit, dirname +from zipfile import ZipFile + +from build import get_numpy_version, get_binary_name + +def get_sdist_tarball(): + """Return the name of the installer built by wininst command.""" + # Yeah, the name logic is harcoded in distutils. We have to reproduce it + # here + name = "numpy-%s.zip" % get_numpy_version() + return name + +def build_sdist(): + cwd = os.getcwd() + try: + os.chdir('../..') + cmd = ["python", "setup.py", "sdist", "--format=zip"] + subprocess.call(cmd) + except Exception, e: + raise RuntimeError("Error while executing cmd (%s)" % e) + finally: + os.chdir(cwd) + +def prepare_numpy_sources(bootstrap = 'bootstrap'): + zid = ZipFile(pjoin('../..', 'dist', get_sdist_tarball())) + root = 'numpy-%s' % get_numpy_version() + + # From the sdist-built tarball, extract all files into bootstrap directory, + # but removing the numpy-VERSION head path + for name in zid.namelist(): + cnt = zid.read(name) + if name.startswith(root): + name = name.split(os.sep, 1)[1] + newname = pjoin(bootstrap, name) + + if not os.path.exists(dirname(newname)): + os.makedirs(dirname(newname)) + fid = open(newname, 'w') + fid.write(cnt) + +def prepare_nsis_script(bootstrap, pyver, numver): + tpl = os.path.join('nsis_scripts', 'numpy-superinstaller.nsi.in') + source = open(tpl, 'r') + target = open(pjoin(bootstrap, 'numpy-superinstaller.nsi'), 'w') + + installer_name = 'numpy-%s-win32-superpack-python%s.exe' % (numver, pyver) + cnt = "".join(source.readlines()) + cnt = cnt.replace('@NUMPY_INSTALLER_NAME@', installer_name) + for arch in ['nosse', 'sse2', 'sse3']: + cnt = cnt.replace('@%s_BINARY@' % arch.upper(), + get_binary_name(arch))) + + target.write(cnt) + +def prepare_bootstrap(pyver = "2.5"): + bootstrap = "bootstrap-%s" % pyver + if os.path.exists(bootstrap): + shutil.rmtree(bootstrap) + os.makedirs(bootstrap) + + #build_sdist() + #prepare_numpy_sources(bootstrap) + + #shutil.copy('build.py', bootstrap) + prepare_nsis_script(bootstrap, pyver, get_numpy_version()) + +if __name__ == '__main__': + prepare_bootstrap("2.5") From numpy-svn at scipy.org Sun Jul 27 22:22:17 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 21:22:17 -0500 (CDT) Subject: [Numpy-svn] r5547 - trunk/tools/win32build Message-ID: <20080728022217.14DCE39C07C@scipy.org> Author: cdavid Date: 2008-07-27 21:22:13 -0500 (Sun, 27 Jul 2008) New Revision: 5547 Modified: trunk/tools/win32build/prepare_bootstrap.py Log: Uncomment bootstrap tasks. Modified: trunk/tools/win32build/prepare_bootstrap.py =================================================================== --- trunk/tools/win32build/prepare_bootstrap.py 2008-07-28 02:21:17 UTC (rev 5546) +++ trunk/tools/win32build/prepare_bootstrap.py 2008-07-28 02:22:13 UTC (rev 5547) @@ -61,10 +61,10 @@ shutil.rmtree(bootstrap) os.makedirs(bootstrap) - #build_sdist() - #prepare_numpy_sources(bootstrap) + build_sdist() + prepare_numpy_sources(bootstrap) - #shutil.copy('build.py', bootstrap) + shutil.copy('build.py', bootstrap) prepare_nsis_script(bootstrap, pyver, get_numpy_version()) if __name__ == '__main__': From numpy-svn at scipy.org Sun Jul 27 22:29:16 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 21:29:16 -0500 (CDT) Subject: [Numpy-svn] r5548 - trunk Message-ID: <20080728022916.6F60239C24E@scipy.org> Author: cdavid Date: 2008-07-27 21:29:13 -0500 (Sun, 27 Jul 2008) New Revision: 5548 Modified: trunk/MANIFEST.in Log: Fixing MANIFEST.in on win32. Modified: trunk/MANIFEST.in =================================================================== --- trunk/MANIFEST.in 2008-07-28 02:22:13 UTC (rev 5547) +++ trunk/MANIFEST.in 2008-07-28 02:29:13 UTC (rev 5548) @@ -10,4 +10,4 @@ # Adding scons build relateed files not found by distutils include numpy/core/code_generators/__init__.py include numpy/core/include/numpy/numpyconfig.h.in -recursive-include numpy/ SConstruct +recursive-include numpy SConstruct From numpy-svn at scipy.org Sun Jul 27 23:49:01 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 22:49:01 -0500 (CDT) Subject: [Numpy-svn] r5549 - trunk Message-ID: <20080728034901.25A2639C24E@scipy.org> Author: cdavid Date: 2008-07-27 22:48:57 -0500 (Sun, 27 Jul 2008) New Revision: 5549 Modified: trunk/MANIFEST.in Log: Add code-generator files in MANIFEST because distutils does not pick them up. Modified: trunk/MANIFEST.in =================================================================== --- trunk/MANIFEST.in 2008-07-28 02:29:13 UTC (rev 5548) +++ trunk/MANIFEST.in 2008-07-28 03:48:57 UTC (rev 5549) @@ -8,6 +8,6 @@ include setupscons.py include setupegg.py # Adding scons build relateed files not found by distutils -include numpy/core/code_generators/__init__.py +recursive-include numpy/core/code_generators *.py include numpy/core/include/numpy/numpyconfig.h.in recursive-include numpy SConstruct From numpy-svn at scipy.org Mon Jul 28 00:20:40 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 23:20:40 -0500 (CDT) Subject: [Numpy-svn] r5550 - trunk/tools/win32build Message-ID: <20080728042040.CB1C139C036@scipy.org> Author: cdavid Date: 2008-07-27 23:20:37 -0500 (Sun, 27 Jul 2008) New Revision: 5550 Modified: trunk/tools/win32build/build.py Log: Build all ARCHS if arch arg not given to build script. Modified: trunk/tools/win32build/build.py =================================================================== --- trunk/tools/win32build/build.py 2008-07-28 03:48:57 UTC (rev 5549) +++ trunk/tools/win32build/build.py 2008-07-28 04:20:37 UTC (rev 5550) @@ -107,10 +107,11 @@ arch = opts.arch pyver = opts.pyver - if not arch: - arch = "nosse" if not pyver: pyver = "2.5" - build(arch, pyver) - #for arch in SITECFG.keys(): - # build(arch, pyver) + + if not arch: + for arch in SITECFG.keys(): + build(arch, pyver) + else: + build(arch, pyver) From numpy-svn at scipy.org Mon Jul 28 00:21:53 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 23:21:53 -0500 (CDT) Subject: [Numpy-svn] r5551 - trunk/tools/win32build/nsis_scripts Message-ID: <20080728042153.85A8139C036@scipy.org> Author: cdavid Date: 2008-07-27 23:21:49 -0500 (Sun, 27 Jul 2008) New Revision: 5551 Modified: trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in Log: Set LZMA solid compressor. Modified: trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in =================================================================== --- trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in 2008-07-28 04:20:37 UTC (rev 5550) +++ trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in 2008-07-28 04:21:49 UTC (rev 5551) @@ -4,6 +4,7 @@ !include "MUI2.nsh" ;SetCompress off ; Useful to disable compression under development +SetCompressor /Solid LZMA ; Useful to disable compression under development ;-------------------------------- ;General From numpy-svn at scipy.org Mon Jul 28 00:22:44 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 23:22:44 -0500 (CDT) Subject: [Numpy-svn] r5552 - trunk/tools/win32build Message-ID: <20080728042244.82F5D39C036@scipy.org> Author: cdavid Date: 2008-07-27 23:22:40 -0500 (Sun, 27 Jul 2008) New Revision: 5552 Modified: trunk/tools/win32build/prepare_bootstrap.py Log: Bootstrap script now works from scratch. Modified: trunk/tools/win32build/prepare_bootstrap.py =================================================================== --- trunk/tools/win32build/prepare_bootstrap.py 2008-07-28 04:21:49 UTC (rev 5551) +++ trunk/tools/win32build/prepare_bootstrap.py 2008-07-28 04:22:40 UTC (rev 5552) @@ -3,9 +3,8 @@ import shutil from os.path import join as pjoin, split as psplit, dirname from zipfile import ZipFile +import re -from build import get_numpy_version, get_binary_name - def get_sdist_tarball(): """Return the name of the installer built by wininst command.""" # Yeah, the name logic is harcoded in distutils. We have to reproduce it @@ -25,7 +24,7 @@ os.chdir(cwd) def prepare_numpy_sources(bootstrap = 'bootstrap'): - zid = ZipFile(pjoin('../..', 'dist', get_sdist_tarball())) + zid = ZipFile(pjoin('..', '..', 'dist', get_sdist_tarball())) root = 'numpy-%s' % get_numpy_version() # From the sdist-built tarball, extract all files into bootstrap directory, @@ -33,12 +32,13 @@ for name in zid.namelist(): cnt = zid.read(name) if name.startswith(root): - name = name.split(os.sep, 1)[1] + # XXX: even on windows, the path sep in zip is '/' ? + name = name.split('/', 1)[1] newname = pjoin(bootstrap, name) if not os.path.exists(dirname(newname)): os.makedirs(dirname(newname)) - fid = open(newname, 'w') + fid = open(newname, 'wb') fid.write(cnt) def prepare_nsis_script(bootstrap, pyver, numver): @@ -51,11 +51,11 @@ cnt = cnt.replace('@NUMPY_INSTALLER_NAME@', installer_name) for arch in ['nosse', 'sse2', 'sse3']: cnt = cnt.replace('@%s_BINARY@' % arch.upper(), - get_binary_name(arch))) + get_binary_name(arch)) target.write(cnt) -def prepare_bootstrap(pyver = "2.5"): +def prepare_bootstrap(numver, pyver = "2.5"): bootstrap = "bootstrap-%s" % pyver if os.path.exists(bootstrap): shutil.rmtree(bootstrap) @@ -67,5 +67,32 @@ shutil.copy('build.py', bootstrap) prepare_nsis_script(bootstrap, pyver, get_numpy_version()) +def get_binary_name(arch): + return "numpy-%s-%s.exe" % (get_numpy_version(), arch) + +def get_numpy_version(chdir = pjoin('..', '..')): + cwd = os.getcwd() + try: + if not chdir: + chdir = cwd + os.chdir(chdir) + version = subprocess.Popen(['python', '-c', 'import __builtin__; __builtin__.__NUMPY_SETUP__ = True; from numpy.version import version;print version'], stdout = subprocess.PIPE).communicate()[0] + version = version.strip() + if 'dev' in version: + out = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE).communicate()[0] + r = re.compile('Revision: ([0-9]+)') + svnver = None + for line in out.split('\n'): + m = r.match(line) + if m: + svnver = m.group(1) + + if not svnver: + raise ValueError("Error while parsing svn version ?") + version += svnver + finally: + os.chdir(cwd) + return version + if __name__ == '__main__': prepare_bootstrap("2.5") From numpy-svn at scipy.org Mon Jul 28 00:39:17 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 23:39:17 -0500 (CDT) Subject: [Numpy-svn] r5553 - trunk/tools/win32build Message-ID: <20080728043917.D1BF339C24E@scipy.org> Author: cdavid Date: 2008-07-27 23:39:13 -0500 (Sun, 27 Jul 2008) New Revision: 5553 Added: trunk/tools/win32build/doall.py Log: Add top script to generate binaries from scratch. Added: trunk/tools/win32build/doall.py =================================================================== --- trunk/tools/win32build/doall.py 2008-07-28 04:22:40 UTC (rev 5552) +++ trunk/tools/win32build/doall.py 2008-07-28 04:39:13 UTC (rev 5553) @@ -0,0 +1,13 @@ +import subprocess +import os + +PYVER = "2.5" + +# Bootstrap +subprocess.check_call(['python', 'prepare_bootstrap.py']) + +# Build binaries +subprocess.check_call(['python', 'build.py', '-p', PYVER], cwd = 'bootstrap-%s' % PYVER) + +# Build installer using nsis +subprocess.check_call(['makensis', 'numpy-superinstaller.nsi'], cwd = 'bootstrap-%s' % PYVER) From numpy-svn at scipy.org Mon Jul 28 00:39:29 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Sun, 27 Jul 2008 23:39:29 -0500 (CDT) Subject: [Numpy-svn] r5554 - trunk/tools/win32build/nsis_scripts Message-ID: <20080728043929.0236C39C24E@scipy.org> Author: cdavid Date: 2008-07-27 23:39:26 -0500 (Sun, 27 Jul 2008) New Revision: 5554 Modified: trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in Log: Fix path issue in nsis script. Modified: trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in =================================================================== --- trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in 2008-07-28 04:39:13 UTC (rev 5553) +++ trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in 2008-07-28 04:39:26 UTC (rev 5554) @@ -93,17 +93,17 @@ ${Switch} $CPUSSE ${Case} "3" DetailPrint '"Install SSE 3"' - File "@SSE3_BINARY@" + File "binaries\@SSE3_BINARY@" ExecWait '"$INSTDIR\@SSE3_BINARY@"' ${Break} ${Case} "2" DetailPrint '"Install SSE 2"' - File "@SSE2_BINARY@" + File "binaries\@SSE2_BINARY@" ExecWait '"$INSTDIR\@SSE2_BINARY@"' ${Break} ${Default} DetailPrint '"Install NO SSE"' - File "@NOSSE_BINARY@" + File "binaries\@NOSSE_BINARY@" ExecWait '"$INSTDIR\@NOSSE_BINARY@"' ${Break} ${EndSwitch} From numpy-svn at scipy.org Mon Jul 28 01:01:51 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 00:01:51 -0500 (CDT) Subject: [Numpy-svn] r5555 - trunk/tools/win32build Message-ID: <20080728050151.D1E4B39C78A@scipy.org> Author: cdavid Date: 2008-07-28 00:01:47 -0500 (Mon, 28 Jul 2008) New Revision: 5555 Modified: trunk/tools/win32build/README.txt Log: Update readme for win32build tools. Modified: trunk/tools/win32build/README.txt =================================================================== --- trunk/tools/win32build/README.txt 2008-07-28 04:39:26 UTC (rev 5554) +++ trunk/tools/win32build/README.txt 2008-07-28 05:01:47 UTC (rev 5555) @@ -1,9 +1,64 @@ -This directory contains various scripts and code to build installers for -windows - - cpuid: contains a mini lib to detect SSE. - - cpucaps: nsis plugin to add the ability to detect SSE for installers. - - *nsi scripts: actual nsis scripts to build the installer - - build.py: script to build various versions of python binaries - (several archs, several python versions) +This directory contains various scripts and code to build binaries installers for +windows. -To build the binaries, you need blas/lapack/atlas for all architectures. +It can: + - prepare a bootstrap environment to build binary in a self-contained + directory + - build binaries for different architectures using different site.cfg + - prepare a nsis-based installer which automatically detects the arch + on the computer where numpy is installed. + +Example: +======== + +python doall.py + +Should build the numpy 'super' installer for sse2, sse3 and nosse from scratch. +You have to run it in the win32build directory. + +Dependencies: +============= + +You need the following to use those scripts: + - python and mingw tools (gcc, make, g77 at least). + - the binaries for atlas/blas/lapack for the various archs supported + (see vendor in numpy repository root for tools to build those). + - python, nsis and subversion command line tools should be in your + PATH, e.g. running python, makensis and svn should work in a DOS + cmd.exe. + - the CpuCaps nsis plugin (see below on how to build it). + +Components: +=========== + +cpuid +----- + +cpuid: contains a mini C lib to detect SSE variants (SSE 1, 2 and 3 for now). +It relies on gcc ASM, but porting it to VS should be trivial (only a few lines +os ASM). + +cpucaps: +-------- + +cpucaps: nsis plugin to add the ability to detect SSE for installers, uses +cpuid. To build it, you have two options: + - build it manually: build the CpuCaps.dll with sources cpucaps.c and + cpuid.c in cpuid directory. + - with scons: if you have scons, just do scons install. It will build + and put the CpuCaps.dll in the plugins directory of nsis (if you + install nsis in the default path). + +build.py: +--------- + +Can build the binaries for each variant of arch in a bootstrap environment + +prepare_bootstrap.py +-------------------- + +Script to prepare a bootstrap environment. A bootstrap environment depends on +the python version (2.5, 2.4, etc...). + +It works by building a source distribution, unzipping it in a bootrap +directory, and putting everything (build.py, nsis script, etc...) in it. From numpy-svn at scipy.org Mon Jul 28 01:08:04 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 00:08:04 -0500 (CDT) Subject: [Numpy-svn] r5556 - trunk/tools/win32build Message-ID: <20080728050804.7C504C7C00D@scipy.org> Author: cdavid Date: 2008-07-28 00:07:59 -0500 (Mon, 28 Jul 2008) New Revision: 5556 Modified: trunk/tools/win32build/prepare_bootstrap.py Log: prepare_bootstrap script now handles pyver correctly, and can be set from command line. Modified: trunk/tools/win32build/prepare_bootstrap.py =================================================================== --- trunk/tools/win32build/prepare_bootstrap.py 2008-07-28 05:01:47 UTC (rev 5555) +++ trunk/tools/win32build/prepare_bootstrap.py 2008-07-28 05:07:59 UTC (rev 5556) @@ -55,7 +55,7 @@ target.write(cnt) -def prepare_bootstrap(numver, pyver = "2.5"): +def prepare_bootstrap(pyver): bootstrap = "bootstrap-%s" % pyver if os.path.exists(bootstrap): shutil.rmtree(bootstrap) @@ -95,4 +95,15 @@ return version if __name__ == '__main__': - prepare_bootstrap("2.5") + from optparse import OptionParser + parser = OptionParser() + parser.add_option("-p", "--pyver", dest="pyver", + help = "Python version (2.4, 2.5, etc...)") + + opts, args = parser.parse_args() + pyver = opts.pyver + + if not pyver: + pyver = "2.5" + + prepare_bootstrap(pyver) From numpy-svn at scipy.org Mon Jul 28 01:22:45 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 00:22:45 -0500 (CDT) Subject: [Numpy-svn] r5557 - trunk/tools/win32build/nsis_scripts Message-ID: <20080728052245.5055E39C90F@scipy.org> Author: cdavid Date: 2008-07-28 00:22:41 -0500 (Mon, 28 Jul 2008) New Revision: 5557 Removed: trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi Log: Remove unused nsis scripts. Deleted: trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi =================================================================== --- trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi 2008-07-28 05:07:59 UTC (rev 5556) +++ trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi 2008-07-28 05:22:41 UTC (rev 5557) @@ -1,120 +0,0 @@ -;-------------------------------- -;Include Modern UI - -!include "MUI2.nsh" - -;SetCompress off ; Useful to disable compression under development - -;-------------------------------- -;General - -;Name and file -Name "Numpy super installer" -OutFile "numpy-1.1.0-win32-superpack-python2.4.exe" - -;Default installation folder -InstallDir "$TEMP" - -;-------------------------------- -;Interface Settings - -!define MUI_ABORTWARNING - -;-------------------------------- -;Pages - -;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" -;!insertmacro MUI_PAGE_COMPONENTS -;!insertmacro MUI_PAGE_DIRECTORY -;!insertmacro MUI_PAGE_INSTFILES - -;!insertmacro MUI_UNPAGE_CONFIRM -;!insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - -!insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Component Sections - -!include 'Sections.nsh' -!include LogicLib.nsh - -Var HasSSE2 -Var HasSSE3 -Var CPUSSE - -Section "Core" SecCore - - ;SectionIn RO - SetOutPath "$INSTDIR" - - ;Create uninstaller - ;WriteUninstaller "$INSTDIR\Uninstall.exe" - - DetailPrint "Install dir for actual installers is $INSTDIR" - - StrCpy $CPUSSE "0" - CpuCaps::hasSSE2 - Pop $0 - StrCpy $HasSSE2 $0 - - CpuCaps::hasSSE3 - Pop $0 - StrCpy $HasSSE3 $0 - - ; Debug - StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 - include_sse2: - DetailPrint '"Target CPU handles SSE2"' - StrCpy $CPUSSE "2" - goto done_sse2 - no_include_sse2: - DetailPrint '"Target CPU does NOT handle SSE2"' - goto done_sse2 - done_sse2: - - StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 - include_sse3: - DetailPrint '"Target CPU handles SSE3"' - StrCpy $CPUSSE "3" - goto done_sse3 - no_include_sse3: - DetailPrint '"Target CPU does NOT handle SSE3"' - goto done_sse3 - done_sse3: - - ClearErrors - - ; Install files conditionaly on detected cpu - ${Switch} $CPUSSE - ${Case} "3" - DetailPrint '"Install SSE 3"' - File "numpy-1.1.0-sse3.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse3.exe"' - ${Break} - ${Case} "2" - DetailPrint '"Install SSE 2"' - File "numpy-1.1.0-sse2.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse2.exe"' - ${Break} - ${Default} - DetailPrint '"Install NO SSE"' - File "numpy-1.1.0-nosse.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-nosse.exe"' - ${Break} - ${EndSwitch} - - ; Handle errors when executing installers - IfErrors error no_error - - error: - messageBox MB_OK "Executing numpy installer failed" - goto done - no_error: - goto done - done: - -SectionEnd Deleted: trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi =================================================================== --- trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi 2008-07-28 05:07:59 UTC (rev 5556) +++ trunk/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi 2008-07-28 05:22:41 UTC (rev 5557) @@ -1,120 +0,0 @@ -;-------------------------------- -;Include Modern UI - -!include "MUI2.nsh" - -;SetCompress off ; Useful to disable compression under development - -;-------------------------------- -;General - -;Name and file -Name "Numpy super installer" -OutFile "numpy-1.1.0-win32-superpack-python2.5.exe" - -;Default installation folder -InstallDir "$TEMP" - -;-------------------------------- -;Interface Settings - -!define MUI_ABORTWARNING - -;-------------------------------- -;Pages - -;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" -;!insertmacro MUI_PAGE_COMPONENTS -;!insertmacro MUI_PAGE_DIRECTORY -;!insertmacro MUI_PAGE_INSTFILES - -;!insertmacro MUI_UNPAGE_CONFIRM -;!insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - -!insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Component Sections - -!include 'Sections.nsh' -!include LogicLib.nsh - -Var HasSSE2 -Var HasSSE3 -Var CPUSSE - -Section "Core" SecCore - - ;SectionIn RO - SetOutPath "$INSTDIR" - - ;Create uninstaller - ;WriteUninstaller "$INSTDIR\Uninstall.exe" - - DetailPrint "Install dir for actual installers is $INSTDIR" - - StrCpy $CPUSSE "0" - CpuCaps::hasSSE2 - Pop $0 - StrCpy $HasSSE2 $0 - - CpuCaps::hasSSE3 - Pop $0 - StrCpy $HasSSE3 $0 - - ; Debug - StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 - include_sse2: - DetailPrint '"Target CPU handles SSE2"' - StrCpy $CPUSSE "2" - goto done_sse2 - no_include_sse2: - DetailPrint '"Target CPU does NOT handle SSE2"' - goto done_sse2 - done_sse2: - - StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 - include_sse3: - DetailPrint '"Target CPU handles SSE3"' - StrCpy $CPUSSE "3" - goto done_sse3 - no_include_sse3: - DetailPrint '"Target CPU does NOT handle SSE3"' - goto done_sse3 - done_sse3: - - ClearErrors - - ; Install files conditionaly on detected cpu - ${Switch} $CPUSSE - ${Case} "3" - DetailPrint '"Install SSE 3"' - File "numpy-1.1.0-sse3.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse3.exe"' - ${Break} - ${Case} "2" - DetailPrint '"Install SSE 2"' - File "numpy-1.1.0-sse2.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse2.exe"' - ${Break} - ${Default} - DetailPrint '"Install NO SSE"' - File "numpy-1.1.0-nosse.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-nosse.exe"' - ${Break} - ${EndSwitch} - - ; Handle errors when executing installers - IfErrors error no_error - - error: - messageBox MB_OK "Executing numpy installer failed" - goto done - no_error: - goto done - done: - -SectionEnd From numpy-svn at scipy.org Mon Jul 28 01:25:09 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 00:25:09 -0500 (CDT) Subject: [Numpy-svn] r5558 - trunk/tools/win32build Message-ID: <20080728052509.AFE5839C9A9@scipy.org> Author: cdavid Date: 2008-07-28 00:25:04 -0500 (Mon, 28 Jul 2008) New Revision: 5558 Modified: trunk/tools/win32build/README.txt trunk/tools/win32build/build.py trunk/tools/win32build/doall.py Log: Set build scripts to unix ff. Modified: trunk/tools/win32build/README.txt =================================================================== --- trunk/tools/win32build/README.txt 2008-07-28 05:22:41 UTC (rev 5557) +++ trunk/tools/win32build/README.txt 2008-07-28 05:25:04 UTC (rev 5558) @@ -1,64 +1,64 @@ -This directory contains various scripts and code to build binaries installers for -windows. - -It can: - - prepare a bootstrap environment to build binary in a self-contained - directory - - build binaries for different architectures using different site.cfg - - prepare a nsis-based installer which automatically detects the arch - on the computer where numpy is installed. - -Example: -======== - -python doall.py - -Should build the numpy 'super' installer for sse2, sse3 and nosse from scratch. -You have to run it in the win32build directory. - -Dependencies: -============= - -You need the following to use those scripts: - - python and mingw tools (gcc, make, g77 at least). - - the binaries for atlas/blas/lapack for the various archs supported - (see vendor in numpy repository root for tools to build those). - - python, nsis and subversion command line tools should be in your - PATH, e.g. running python, makensis and svn should work in a DOS - cmd.exe. - - the CpuCaps nsis plugin (see below on how to build it). - -Components: -=========== - -cpuid ------ - -cpuid: contains a mini C lib to detect SSE variants (SSE 1, 2 and 3 for now). -It relies on gcc ASM, but porting it to VS should be trivial (only a few lines -os ASM). - -cpucaps: --------- - -cpucaps: nsis plugin to add the ability to detect SSE for installers, uses -cpuid. To build it, you have two options: - - build it manually: build the CpuCaps.dll with sources cpucaps.c and - cpuid.c in cpuid directory. - - with scons: if you have scons, just do scons install. It will build - and put the CpuCaps.dll in the plugins directory of nsis (if you - install nsis in the default path). - -build.py: ---------- - -Can build the binaries for each variant of arch in a bootstrap environment - -prepare_bootstrap.py --------------------- - -Script to prepare a bootstrap environment. A bootstrap environment depends on -the python version (2.5, 2.4, etc...). - -It works by building a source distribution, unzipping it in a bootrap -directory, and putting everything (build.py, nsis script, etc...) in it. +This directory contains various scripts and code to build binaries installers for +windows. + +It can: + - prepare a bootstrap environment to build binary in a self-contained + directory + - build binaries for different architectures using different site.cfg + - prepare a nsis-based installer which automatically detects the arch + on the computer where numpy is installed. + +Example: +======== + +python doall.py + +Should build the numpy 'super' installer for sse2, sse3 and nosse from scratch. +You have to run it in the win32build directory. + +Dependencies: +============= + +You need the following to use those scripts: + - python and mingw tools (gcc, make, g77 at least). + - the binaries for atlas/blas/lapack for the various archs supported + (see vendor in numpy repository root for tools to build those). + - python, nsis and subversion command line tools should be in your + PATH, e.g. running python, makensis and svn should work in a DOS + cmd.exe. + - the CpuCaps nsis plugin (see below on how to build it). + +Components: +=========== + +cpuid +----- + +cpuid: contains a mini C lib to detect SSE variants (SSE 1, 2 and 3 for now). +It relies on gcc ASM, but porting it to VS should be trivial (only a few lines +os ASM). + +cpucaps: +-------- + +cpucaps: nsis plugin to add the ability to detect SSE for installers, uses +cpuid. To build it, you have two options: + - build it manually: build the CpuCaps.dll with sources cpucaps.c and + cpuid.c in cpuid directory. + - with scons: if you have scons, just do scons install. It will build + and put the CpuCaps.dll in the plugins directory of nsis (if you + install nsis in the default path). + +build.py: +--------- + +Can build the binaries for each variant of arch in a bootstrap environment + +prepare_bootstrap.py +-------------------- + +Script to prepare a bootstrap environment. A bootstrap environment depends on +the python version (2.5, 2.4, etc...). + +It works by building a source distribution, unzipping it in a bootrap +directory, and putting everything (build.py, nsis script, etc...) in it. Modified: trunk/tools/win32build/build.py =================================================================== --- trunk/tools/win32build/build.py 2008-07-28 05:22:41 UTC (rev 5557) +++ trunk/tools/win32build/build.py 2008-07-28 05:25:04 UTC (rev 5558) @@ -1,117 +1,117 @@ -"""Python script to build windows binaries to be fed to the "superpack". - -The script is pretty dumb: it assumes python executables are installed the -standard way, and the location for blas/lapack/atlas is harcoded.""" - -# TODO: -# - integrate the x86analysis script to check built binaries -# - make the config configurable with a file -import sys -import subprocess -import os -import shutil -from os.path import join as pjoin, split as psplit, dirname - -PYEXECS = {"2.5" : "C:\python25\python.exe", - "2.4" : "C:\python24\python2.4.exe"} - -_SSE3_CFG = r"""[atlas] -library_dirs = C:\local\lib\yop\sse3""" -_SSE2_CFG = r"""[atlas] -library_dirs = C:\local\lib\yop\sse2""" -_NOSSE_CFG = r"""[DEFAULT] -library_dirs = C:\local\lib\yop\nosse""" - -SITECFG = {"sse2" : _SSE2_CFG, "sse3" : _SSE3_CFG, "nosse" : _NOSSE_CFG} - -def get_python_exec(ver): - """Return the executable of python for the given version.""" - # XXX Check that the file actually exists - try: - return PYEXECS[ver] - except KeyError: - raise ValueError("Version %s not supported/recognized" % ver) - -def get_clean(): - if os.path.exists("build"): - shutil.rmtree("build") - if os.path.exists("dist"): - shutil.rmtree("dist") - -def write_site_cfg(arch): - if os.path.exists("site.cfg"): - os.remove("site.cfg") - f = open("site.cfg", 'w') - f.writelines(SITECFG[arch]) - f.close() - -def build(arch, pyver): - print "Building numpy binary for python %s, arch is %s" % (get_python_exec(pyver), arch) - get_clean() - write_site_cfg(arch) - - cmd = "%s setup.py build -c mingw32 bdist_wininst" % get_python_exec(pyver) - build_log = "build-%s-%s.log" % (arch, pyver) - f = open(build_log, 'w') - - try: - try: - subprocess.check_call(cmd, shell = True, stderr = subprocess.STDOUT, stdout = f) - finally: - f.close() - except subprocess.CalledProcessError, e: - msg = """ -There was an error while executing the following command: - - %s - -Error was : %s - -Look at the build log (%s).""" % (cmd, str(e), build_log) - raise Exception(msg) - - move_binary(arch, pyver) - -def move_binary(arch, pyver): - if not os.path.exists("binaries"): - os.makedirs("binaries") - - shutil.move(os.path.join('dist', get_windist_exec(pyver)), - os.path.join("binaries", get_binary_name(arch))) - -def get_numpy_version(): - import __builtin__ - __builtin__.__NUMPY_SETUP__ = True - from numpy.version import version - return version - -def get_binary_name(arch): - return "numpy-%s-%s.exe" % (get_numpy_version(), arch) - -def get_windist_exec(pyver): - """Return the name of the installer built by wininst command.""" - # Yeah, the name logic is harcoded in distutils. We have to reproduce it - # here - name = "numpy-%s.win32-py%s.exe" % (get_numpy_version(), pyver) - return name - -if __name__ == '__main__': - from optparse import OptionParser - parser = OptionParser() - parser.add_option("-a", "--arch", dest="arch", - help = "Architecture to build (sse2, sse3, nosse, etc...)") - parser.add_option("-p", "--pyver", dest="pyver", - help = "Python version (2.4, 2.5, etc...)") - - opts, args = parser.parse_args() - arch = opts.arch - pyver = opts.pyver - - if not pyver: - pyver = "2.5" - - if not arch: - for arch in SITECFG.keys(): - build(arch, pyver) - else: - build(arch, pyver) +"""Python script to build windows binaries to be fed to the "superpack". + +The script is pretty dumb: it assumes python executables are installed the +standard way, and the location for blas/lapack/atlas is harcoded.""" + +# TODO: +# - integrate the x86analysis script to check built binaries +# - make the config configurable with a file +import sys +import subprocess +import os +import shutil +from os.path import join as pjoin, split as psplit, dirname + +PYEXECS = {"2.5" : "C:\python25\python.exe", + "2.4" : "C:\python24\python2.4.exe"} + +_SSE3_CFG = r"""[atlas] +library_dirs = C:\local\lib\yop\sse3""" +_SSE2_CFG = r"""[atlas] +library_dirs = C:\local\lib\yop\sse2""" +_NOSSE_CFG = r"""[DEFAULT] +library_dirs = C:\local\lib\yop\nosse""" + +SITECFG = {"sse2" : _SSE2_CFG, "sse3" : _SSE3_CFG, "nosse" : _NOSSE_CFG} + +def get_python_exec(ver): + """Return the executable of python for the given version.""" + # XXX Check that the file actually exists + try: + return PYEXECS[ver] + except KeyError: + raise ValueError("Version %s not supported/recognized" % ver) + +def get_clean(): + if os.path.exists("build"): + shutil.rmtree("build") + if os.path.exists("dist"): + shutil.rmtree("dist") + +def write_site_cfg(arch): + if os.path.exists("site.cfg"): + os.remove("site.cfg") + f = open("site.cfg", 'w') + f.writelines(SITECFG[arch]) + f.close() + +def build(arch, pyver): + print "Building numpy binary for python %s, arch is %s" % (get_python_exec(pyver), arch) + get_clean() + write_site_cfg(arch) + + cmd = "%s setup.py build -c mingw32 bdist_wininst" % get_python_exec(pyver) + build_log = "build-%s-%s.log" % (arch, pyver) + f = open(build_log, 'w') + + try: + try: + subprocess.check_call(cmd, shell = True, stderr = subprocess.STDOUT, stdout = f) + finally: + f.close() + except subprocess.CalledProcessError, e: + msg = """ +There was an error while executing the following command: + + %s + +Error was : %s + +Look at the build log (%s).""" % (cmd, str(e), build_log) + raise Exception(msg) + + move_binary(arch, pyver) + +def move_binary(arch, pyver): + if not os.path.exists("binaries"): + os.makedirs("binaries") + + shutil.move(os.path.join('dist', get_windist_exec(pyver)), + os.path.join("binaries", get_binary_name(arch))) + +def get_numpy_version(): + import __builtin__ + __builtin__.__NUMPY_SETUP__ = True + from numpy.version import version + return version + +def get_binary_name(arch): + return "numpy-%s-%s.exe" % (get_numpy_version(), arch) + +def get_windist_exec(pyver): + """Return the name of the installer built by wininst command.""" + # Yeah, the name logic is harcoded in distutils. We have to reproduce it + # here + name = "numpy-%s.win32-py%s.exe" % (get_numpy_version(), pyver) + return name + +if __name__ == '__main__': + from optparse import OptionParser + parser = OptionParser() + parser.add_option("-a", "--arch", dest="arch", + help = "Architecture to build (sse2, sse3, nosse, etc...)") + parser.add_option("-p", "--pyver", dest="pyver", + help = "Python version (2.4, 2.5, etc...)") + + opts, args = parser.parse_args() + arch = opts.arch + pyver = opts.pyver + + if not pyver: + pyver = "2.5" + + if not arch: + for arch in SITECFG.keys(): + build(arch, pyver) + else: + build(arch, pyver) Modified: trunk/tools/win32build/doall.py =================================================================== --- trunk/tools/win32build/doall.py 2008-07-28 05:22:41 UTC (rev 5557) +++ trunk/tools/win32build/doall.py 2008-07-28 05:25:04 UTC (rev 5558) @@ -1,13 +1,13 @@ -import subprocess -import os - -PYVER = "2.5" - -# Bootstrap -subprocess.check_call(['python', 'prepare_bootstrap.py']) - -# Build binaries -subprocess.check_call(['python', 'build.py', '-p', PYVER], cwd = 'bootstrap-%s' % PYVER) - -# Build installer using nsis -subprocess.check_call(['makensis', 'numpy-superinstaller.nsi'], cwd = 'bootstrap-%s' % PYVER) +import subprocess +import os + +PYVER = "2.5" + +# Bootstrap +subprocess.check_call(['python', 'prepare_bootstrap.py']) + +# Build binaries +subprocess.check_call(['python', 'build.py', '-p', PYVER], cwd = 'bootstrap-%s' % PYVER) + +# Build installer using nsis +subprocess.check_call(['makensis', 'numpy-superinstaller.nsi'], cwd = 'bootstrap-%s' % PYVER) From numpy-svn at scipy.org Mon Jul 28 01:28:34 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 00:28:34 -0500 (CDT) Subject: [Numpy-svn] r5559 - in branches/1.1.x: . tools/win32build tools/win32build/nsis_scripts Message-ID: <20080728052834.46F0839C9B3@scipy.org> Author: cdavid Date: 2008-07-28 00:28:21 -0500 (Mon, 28 Jul 2008) New Revision: 5559 Added: branches/1.1.x/tools/win32build/doall.py branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in branches/1.1.x/tools/win32build/prepare_bootstrap.py Removed: branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi Modified: branches/1.1.x/MANIFEST.in branches/1.1.x/tools/win32build/README.txt branches/1.1.x/tools/win32build/build.py Log: Backport win32build improvements + MANIFEST.in fix. Modified: branches/1.1.x/MANIFEST.in =================================================================== --- branches/1.1.x/MANIFEST.in 2008-07-28 05:25:04 UTC (rev 5558) +++ branches/1.1.x/MANIFEST.in 2008-07-28 05:28:21 UTC (rev 5559) @@ -8,6 +8,6 @@ include setupscons.py include setupegg.py # Adding scons build relateed files not found by distutils -include numpy/core/code_generators/__init__.py +recursive-include numpy/core/code_generators *.py include numpy/core/include/numpy/numpyconfig.h.in -recursive-include numpy/ SConstruct +recursive-include numpy SConstruct Modified: branches/1.1.x/tools/win32build/README.txt =================================================================== --- branches/1.1.x/tools/win32build/README.txt 2008-07-28 05:25:04 UTC (rev 5558) +++ branches/1.1.x/tools/win32build/README.txt 2008-07-28 05:28:21 UTC (rev 5559) @@ -1,9 +1,64 @@ -This directory contains various scripts and code to build installers for -windows - - cpuid: contains a mini lib to detect SSE. - - cpucaps: nsis plugin to add the ability to detect SSE for installers. - - *nsi scripts: actual nsis scripts to build the installer - - build.py: script to build various versions of python binaries - (several archs, several python versions) - -To build the binaries, you need blas/lapack/atlas for all architectures. +This directory contains various scripts and code to build binaries installers for +windows. + +It can: + - prepare a bootstrap environment to build binary in a self-contained + directory + - build binaries for different architectures using different site.cfg + - prepare a nsis-based installer which automatically detects the arch + on the computer where numpy is installed. + +Example: +======== + +python doall.py + +Should build the numpy 'super' installer for sse2, sse3 and nosse from scratch. +You have to run it in the win32build directory. + +Dependencies: +============= + +You need the following to use those scripts: + - python and mingw tools (gcc, make, g77 at least). + - the binaries for atlas/blas/lapack for the various archs supported + (see vendor in numpy repository root for tools to build those). + - python, nsis and subversion command line tools should be in your + PATH, e.g. running python, makensis and svn should work in a DOS + cmd.exe. + - the CpuCaps nsis plugin (see below on how to build it). + +Components: +=========== + +cpuid +----- + +cpuid: contains a mini C lib to detect SSE variants (SSE 1, 2 and 3 for now). +It relies on gcc ASM, but porting it to VS should be trivial (only a few lines +os ASM). + +cpucaps: +-------- + +cpucaps: nsis plugin to add the ability to detect SSE for installers, uses +cpuid. To build it, you have two options: + - build it manually: build the CpuCaps.dll with sources cpucaps.c and + cpuid.c in cpuid directory. + - with scons: if you have scons, just do scons install. It will build + and put the CpuCaps.dll in the plugins directory of nsis (if you + install nsis in the default path). + +build.py: +--------- + +Can build the binaries for each variant of arch in a bootstrap environment + +prepare_bootstrap.py +-------------------- + +Script to prepare a bootstrap environment. A bootstrap environment depends on +the python version (2.5, 2.4, etc...). + +It works by building a source distribution, unzipping it in a bootrap +directory, and putting everything (build.py, nsis script, etc...) in it. Modified: branches/1.1.x/tools/win32build/build.py =================================================================== --- branches/1.1.x/tools/win32build/build.py 2008-07-28 05:25:04 UTC (rev 5558) +++ branches/1.1.x/tools/win32build/build.py 2008-07-28 05:28:21 UTC (rev 5559) @@ -1,110 +1,117 @@ -"""Python script to build windows binaries to be fed to the "superpack". - -The script is pretty dumb: it assumes python executables are installed the -standard way, and the location for blas/lapack/atlas is harcoded.""" - -# TODO: -# - integrate the x86analysis script to check built binaries -# - make the config configurable with a file -import sys -import subprocess -import os -import shutil - -PYEXECS = {"2.5" : "C:\python25\python.exe", - "2.4" : "C:\python24\python2.4.exe"} - -_SSE3_CFG = r"""[atlas] -library_dirs = C:\local\lib\yop\sse3""" -_SSE2_CFG = r"""[atlas] -library_dirs = C:\local\lib\yop\sse2""" -_NOSSE_CFG = r"""[DEFAULT] -library_dirs = C:\local\lib\yop\nosse""" - -SITECFG = {"sse2" : _SSE2_CFG, "sse3" : _SSE3_CFG, "nosse" : _NOSSE_CFG} - -def get_python_exec(ver): - """Return the executable of python for the given version.""" - # XXX Check that the file actually exists - try: - return PYEXECS[ver] - except KeyError: - raise ValueError("Version %s not supported/recognized" % ver) - -def get_clean(): - if os.path.exists("build"): - shutil.rmtree("build") - if os.path.exists("dist"): - shutil.rmtree("dist") - -def write_site_cfg(arch): - if os.path.exists("site.cfg"): - os.remove("site.cfg") - f = open("site.cfg", 'w') - f.writelines(SITECFG[arch]) - f.close() - -def build(arch, pyver): - print "Building numpy binary for python %s, arch is %s" % (get_python_exec(pyver), arch) - get_clean() - write_site_cfg(arch) - - cmd = "%s setup.py build -c mingw32 bdist_wininst" % get_python_exec(pyver) - build_log = "build-%s-%s.log" % (arch, pyver) - f = open(build_log, 'w') - - try: - try: - subprocess.check_call(cmd, shell = True, stderr = subprocess.STDOUT, stdout = f) - finally: - f.close() - except subprocess.CalledProcessError, e: - msg = """ -There was an error while executing the following command: - - %s - -Error was : %s - -Look at the build log (%s).""" % (cmd, str(e), build_log) - raise Exception(msg) - - move_binary(arch, pyver) - -def move_binary(arch, pyver): - if not os.path.exists("binaries"): - os.makedirs("binaries") - - shutil.move(os.path.join('dist', get_windist_exec(pyver)), - os.path.join("binaries", get_binary_name(arch))) - -def get_numpy_version(): - import __builtin__ - __builtin__.__NUMPY_SETUP__ = True - from numpy.version import version - return version - -def get_binary_name(arch): - return "numpy-%s-%s.exe" % (get_numpy_version(), arch) - -def get_windist_exec(pyver): - """Return the name of the installer built by wininst command.""" - # Yeah, the name logic is harcoded in distutils. We have to reproduce it - # here - name = "numpy-%s.win32-py%s.exe" % (get_numpy_version(), pyver) - return name - -USAGE = """build.py ARCH PYTHON_VERSION - -Example: build.py sse2 2.4.""" - -if __name__ == '__main__': - if len(sys.argv) < 3: - raise ValueError(USAGE) - sys.exit(-1) - - arch = sys.argv[1] - pyver = sys.argv[2] - #build(arch, pyver) - for arch in SITECFG.keys(): - build(arch, pyver) +"""Python script to build windows binaries to be fed to the "superpack". + +The script is pretty dumb: it assumes python executables are installed the +standard way, and the location for blas/lapack/atlas is harcoded.""" + +# TODO: +# - integrate the x86analysis script to check built binaries +# - make the config configurable with a file +import sys +import subprocess +import os +import shutil +from os.path import join as pjoin, split as psplit, dirname + +PYEXECS = {"2.5" : "C:\python25\python.exe", + "2.4" : "C:\python24\python2.4.exe"} + +_SSE3_CFG = r"""[atlas] +library_dirs = C:\local\lib\yop\sse3""" +_SSE2_CFG = r"""[atlas] +library_dirs = C:\local\lib\yop\sse2""" +_NOSSE_CFG = r"""[DEFAULT] +library_dirs = C:\local\lib\yop\nosse""" + +SITECFG = {"sse2" : _SSE2_CFG, "sse3" : _SSE3_CFG, "nosse" : _NOSSE_CFG} + +def get_python_exec(ver): + """Return the executable of python for the given version.""" + # XXX Check that the file actually exists + try: + return PYEXECS[ver] + except KeyError: + raise ValueError("Version %s not supported/recognized" % ver) + +def get_clean(): + if os.path.exists("build"): + shutil.rmtree("build") + if os.path.exists("dist"): + shutil.rmtree("dist") + +def write_site_cfg(arch): + if os.path.exists("site.cfg"): + os.remove("site.cfg") + f = open("site.cfg", 'w') + f.writelines(SITECFG[arch]) + f.close() + +def build(arch, pyver): + print "Building numpy binary for python %s, arch is %s" % (get_python_exec(pyver), arch) + get_clean() + write_site_cfg(arch) + + cmd = "%s setup.py build -c mingw32 bdist_wininst" % get_python_exec(pyver) + build_log = "build-%s-%s.log" % (arch, pyver) + f = open(build_log, 'w') + + try: + try: + subprocess.check_call(cmd, shell = True, stderr = subprocess.STDOUT, stdout = f) + finally: + f.close() + except subprocess.CalledProcessError, e: + msg = """ +There was an error while executing the following command: + + %s + +Error was : %s + +Look at the build log (%s).""" % (cmd, str(e), build_log) + raise Exception(msg) + + move_binary(arch, pyver) + +def move_binary(arch, pyver): + if not os.path.exists("binaries"): + os.makedirs("binaries") + + shutil.move(os.path.join('dist', get_windist_exec(pyver)), + os.path.join("binaries", get_binary_name(arch))) + +def get_numpy_version(): + import __builtin__ + __builtin__.__NUMPY_SETUP__ = True + from numpy.version import version + return version + +def get_binary_name(arch): + return "numpy-%s-%s.exe" % (get_numpy_version(), arch) + +def get_windist_exec(pyver): + """Return the name of the installer built by wininst command.""" + # Yeah, the name logic is harcoded in distutils. We have to reproduce it + # here + name = "numpy-%s.win32-py%s.exe" % (get_numpy_version(), pyver) + return name + +if __name__ == '__main__': + from optparse import OptionParser + parser = OptionParser() + parser.add_option("-a", "--arch", dest="arch", + help = "Architecture to build (sse2, sse3, nosse, etc...)") + parser.add_option("-p", "--pyver", dest="pyver", + help = "Python version (2.4, 2.5, etc...)") + + opts, args = parser.parse_args() + arch = opts.arch + pyver = opts.pyver + + if not pyver: + pyver = "2.5" + + if not arch: + for arch in SITECFG.keys(): + build(arch, pyver) + else: + build(arch, pyver) Copied: branches/1.1.x/tools/win32build/doall.py (from rev 5558, trunk/tools/win32build/doall.py) Deleted: branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi =================================================================== --- branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi 2008-07-28 05:25:04 UTC (rev 5558) +++ branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.4.nsi 2008-07-28 05:28:21 UTC (rev 5559) @@ -1,120 +0,0 @@ -;-------------------------------- -;Include Modern UI - -!include "MUI2.nsh" - -;SetCompress off ; Useful to disable compression under development - -;-------------------------------- -;General - -;Name and file -Name "Numpy super installer" -OutFile "numpy-1.1.0-win32-superpack-python2.4.exe" - -;Default installation folder -InstallDir "$TEMP" - -;-------------------------------- -;Interface Settings - -!define MUI_ABORTWARNING - -;-------------------------------- -;Pages - -;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" -;!insertmacro MUI_PAGE_COMPONENTS -;!insertmacro MUI_PAGE_DIRECTORY -;!insertmacro MUI_PAGE_INSTFILES - -;!insertmacro MUI_UNPAGE_CONFIRM -;!insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - -!insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Component Sections - -!include 'Sections.nsh' -!include LogicLib.nsh - -Var HasSSE2 -Var HasSSE3 -Var CPUSSE - -Section "Core" SecCore - - ;SectionIn RO - SetOutPath "$INSTDIR" - - ;Create uninstaller - ;WriteUninstaller "$INSTDIR\Uninstall.exe" - - DetailPrint "Install dir for actual installers is $INSTDIR" - - StrCpy $CPUSSE "0" - CpuCaps::hasSSE2 - Pop $0 - StrCpy $HasSSE2 $0 - - CpuCaps::hasSSE3 - Pop $0 - StrCpy $HasSSE3 $0 - - ; Debug - StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 - include_sse2: - DetailPrint '"Target CPU handles SSE2"' - StrCpy $CPUSSE "2" - goto done_sse2 - no_include_sse2: - DetailPrint '"Target CPU does NOT handle SSE2"' - goto done_sse2 - done_sse2: - - StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 - include_sse3: - DetailPrint '"Target CPU handles SSE3"' - StrCpy $CPUSSE "3" - goto done_sse3 - no_include_sse3: - DetailPrint '"Target CPU does NOT handle SSE3"' - goto done_sse3 - done_sse3: - - ClearErrors - - ; Install files conditionaly on detected cpu - ${Switch} $CPUSSE - ${Case} "3" - DetailPrint '"Install SSE 3"' - File "numpy-1.1.0-sse3.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse3.exe"' - ${Break} - ${Case} "2" - DetailPrint '"Install SSE 2"' - File "numpy-1.1.0-sse2.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse2.exe"' - ${Break} - ${Default} - DetailPrint '"Install NO SSE"' - File "numpy-1.1.0-nosse.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-nosse.exe"' - ${Break} - ${EndSwitch} - - ; Handle errors when executing installers - IfErrors error no_error - - error: - messageBox MB_OK "Executing numpy installer failed" - goto done - no_error: - goto done - done: - -SectionEnd Deleted: branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi =================================================================== --- branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi 2008-07-28 05:25:04 UTC (rev 5558) +++ branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller-2.5.nsi 2008-07-28 05:28:21 UTC (rev 5559) @@ -1,120 +0,0 @@ -;-------------------------------- -;Include Modern UI - -!include "MUI2.nsh" - -;SetCompress off ; Useful to disable compression under development - -;-------------------------------- -;General - -;Name and file -Name "Numpy super installer" -OutFile "numpy-1.1.0-win32-superpack-python2.5.exe" - -;Default installation folder -InstallDir "$TEMP" - -;-------------------------------- -;Interface Settings - -!define MUI_ABORTWARNING - -;-------------------------------- -;Pages - -;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" -;!insertmacro MUI_PAGE_COMPONENTS -;!insertmacro MUI_PAGE_DIRECTORY -;!insertmacro MUI_PAGE_INSTFILES - -;!insertmacro MUI_UNPAGE_CONFIRM -;!insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - -!insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Component Sections - -!include 'Sections.nsh' -!include LogicLib.nsh - -Var HasSSE2 -Var HasSSE3 -Var CPUSSE - -Section "Core" SecCore - - ;SectionIn RO - SetOutPath "$INSTDIR" - - ;Create uninstaller - ;WriteUninstaller "$INSTDIR\Uninstall.exe" - - DetailPrint "Install dir for actual installers is $INSTDIR" - - StrCpy $CPUSSE "0" - CpuCaps::hasSSE2 - Pop $0 - StrCpy $HasSSE2 $0 - - CpuCaps::hasSSE3 - Pop $0 - StrCpy $HasSSE3 $0 - - ; Debug - StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2 - include_sse2: - DetailPrint '"Target CPU handles SSE2"' - StrCpy $CPUSSE "2" - goto done_sse2 - no_include_sse2: - DetailPrint '"Target CPU does NOT handle SSE2"' - goto done_sse2 - done_sse2: - - StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3 - include_sse3: - DetailPrint '"Target CPU handles SSE3"' - StrCpy $CPUSSE "3" - goto done_sse3 - no_include_sse3: - DetailPrint '"Target CPU does NOT handle SSE3"' - goto done_sse3 - done_sse3: - - ClearErrors - - ; Install files conditionaly on detected cpu - ${Switch} $CPUSSE - ${Case} "3" - DetailPrint '"Install SSE 3"' - File "numpy-1.1.0-sse3.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse3.exe"' - ${Break} - ${Case} "2" - DetailPrint '"Install SSE 2"' - File "numpy-1.1.0-sse2.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-sse2.exe"' - ${Break} - ${Default} - DetailPrint '"Install NO SSE"' - File "numpy-1.1.0-nosse.exe" - ExecWait '"$INSTDIR\numpy-1.1.0-nosse.exe"' - ${Break} - ${EndSwitch} - - ; Handle errors when executing installers - IfErrors error no_error - - error: - messageBox MB_OK "Executing numpy installer failed" - goto done - no_error: - goto done - done: - -SectionEnd Copied: branches/1.1.x/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in (from rev 5558, trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in) Copied: branches/1.1.x/tools/win32build/prepare_bootstrap.py (from rev 5558, trunk/tools/win32build/prepare_bootstrap.py) From numpy-svn at scipy.org Mon Jul 28 02:06:21 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 01:06:21 -0500 (CDT) Subject: [Numpy-svn] r5560 - vendor Message-ID: <20080728060621.B3BFF39C02A@scipy.org> Author: cdavid Date: 2008-07-28 01:06:17 -0500 (Mon, 28 Jul 2008) New Revision: 5560 Modified: vendor/README.txt Log: Update readme. Modified: vendor/README.txt =================================================================== --- vendor/README.txt 2008-07-28 05:28:21 UTC (rev 5559) +++ vendor/README.txt 2008-07-28 06:06:17 UTC (rev 5560) @@ -59,3 +59,7 @@ ProcessTerminate. To stop atlas build is not easy either: even from cygwin shell, you cannot stop it easily. The easiest way I am aware of is to kill the AtlasTee.exe process (from cygwin or from the windows TaksManager). + +For this reason, for now, the build.py always starts from scratch. A better +solution would be to use a build system like rake or scons. But rake would mean +more dependencies, and scons is too slow. From numpy-svn at scipy.org Mon Jul 28 02:09:03 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 01:09:03 -0500 (CDT) Subject: [Numpy-svn] r5561 - vendor/tools Message-ID: <20080728060903.D0CFF39C02A@scipy.org> Author: cdavid Date: 2008-07-28 01:08:59 -0500 (Mon, 28 Jul 2008) New Revision: 5561 Modified: vendor/tools/build.py vendor/tools/nosse.cfg Log: Add code to build blas-lapack tarball, and set paths in sync with nsis scripts in generated tarballs. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-28 06:06:17 UTC (rev 5560) +++ vendor/tools/build.py 2008-07-28 06:08:59 UTC (rev 5561) @@ -3,7 +3,7 @@ from subprocess import Popen import shutil import os.path -from os.path import join as pjoin, dirname, abspath +from os.path import join as pjoin, dirname, abspath, basename import glob import tarfile from ConfigParser import ConfigParser @@ -16,6 +16,8 @@ # All path are relative to top directory (vendor) LAPACK_SRC = pjoin('src', 'lapack-lite-3.1.1') LAPACK_LIB = abspath(pjoin(LAPACK_SRC, 'lapack_MINGW32.a')) +BLAS_LIB = abspath(pjoin(LAPACK_SRC, 'blas_MINGW32.a')) +LAPACK_TARBALL = 'lapack-3.1.1.tbz2' ATLAS_SRC = pjoin('src', 'atlas-3.8.2') ATLAS_BUILDDIR = pjoin(ATLAS_SRC, "MyObj") # Use INT_ETIME for lapack if building with gfortran @@ -27,10 +29,22 @@ fid = tarfile.open(ATLAS_TARBALL, 'w:bz2') try: for f in files: + af = pjoin(ARCH.lower(), 'mingw32', basename(f)) fid.add(f) finally: fid.close() +def build_lapack_tarball(): + print "====== Building BLAS/LAPACK tarbal ======" + fid = tarfile.open(LAPACK_TARBALL, 'w:bz2') + try: + af = pjoin(ARCH.lower(), 'mingw32', 'libblas.a') + fid.add(BLAS_LIB, af) + af = pjoin(ARCH.lower(), 'mingw32', 'liblapack.a') + fid.add(LAPACK_LIB, af) + finally: + fid.close() + def build_atlas(): print "====== Building ATLAS ======" p = Popen(['make'], cwd = ATLAS_BUILDDIR) @@ -75,7 +89,7 @@ TARGETS = {'atlas' : [configure_atlas, build_atlas, build_atlas_tarball], 'lapack' : [build_lapack], - 'blas' : [build_blas]} + 'blas-lapack' : [build_blas, build_lapack, build_lapack_tarball]} class Config(object): def __init__(self): Modified: vendor/tools/nosse.cfg =================================================================== --- vendor/tools/nosse.cfg 2008-07-28 06:06:17 UTC (rev 5560) +++ vendor/tools/nosse.cfg 2008-07-28 06:08:59 UTC (rev 5561) @@ -5,6 +5,6 @@ # Pointer Width in bits (Not well detected by ATLAS on Windows at least) PW = 32 [BUILD_OPTIONS] -TARGETS = blas,lapack -LAPACK_F77FLAGS = -O3,-funroll-loops +TARGETS = blas-lapack +#LAPACK_F77FLAGS = -O3,-funroll-loops F77 = g77 From numpy-svn at scipy.org Mon Jul 28 02:11:02 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 01:11:02 -0500 (CDT) Subject: [Numpy-svn] r5562 - vendor/tools Message-ID: <20080728061102.73A4539C02A@scipy.org> Author: cdavid Date: 2008-07-28 01:10:59 -0500 (Mon, 28 Jul 2008) New Revision: 5562 Modified: vendor/tools/build.py Log: Clean everything when cleaning blas/lapack. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-28 06:08:59 UTC (rev 5561) +++ vendor/tools/build.py 2008-07-28 06:10:59 UTC (rev 5562) @@ -73,11 +73,17 @@ p = Popen(['make', 'cleanlib'], cwd = LAPACK_SRC) os.waitpid(p.pid, 0) + p = Popen(['make', 'cleanall'], cwd = LAPACK_SRC) + os.waitpid(p.pid, 0) + def clean_blas(): print "====== Clean BLAS ======" p = Popen(['make', 'clean'], cwd = LAPACK_SRC) os.waitpid(p.pid, 0) + p = Popen(['make', 'cleanall'], cwd = LAPACK_SRC) + os.waitpid(p.pid, 0) + def clean_atlas(): print "====== Clean ATLAS ======" if os.path.exists(ATLAS_BUILDDIR): From numpy-svn at scipy.org Mon Jul 28 02:12:44 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 01:12:44 -0500 (CDT) Subject: [Numpy-svn] r5563 - vendor/tools Message-ID: <20080728061244.14E3839C65B@scipy.org> Author: cdavid Date: 2008-07-28 01:12:41 -0500 (Mon, 28 Jul 2008) New Revision: 5563 Modified: vendor/tools/build.py Log: Add option to clean everything from command line. Modified: vendor/tools/build.py =================================================================== --- vendor/tools/build.py 2008-07-28 06:10:59 UTC (rev 5562) +++ vendor/tools/build.py 2008-07-28 06:12:41 UTC (rev 5563) @@ -142,20 +142,23 @@ if __name__ == '__main__': argc = len(sys.argv) - if argc < 2: - cfg = Config() + if '-c' in sys.argv: + clean() else: - cfg = read_config(sys.argv[1]) + if argc < 2: + cfg = Config() + else: + cfg = read_config(sys.argv[1]) - ARCH = cfg.arch - FC = cfg.f77 - LAPACK_F77_FLAGS = cfg.lapack_flags - ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH - ATLAS_PW = cfg.pw - ATLAS_MHZ = cfg.freq + ARCH = cfg.arch + FC = cfg.f77 + LAPACK_F77_FLAGS = cfg.lapack_flags + ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH + ATLAS_PW = cfg.pw + ATLAS_MHZ = cfg.freq - clean() - for t in cfg.targets: - target = TARGETS[t] - for action in target: - action() + clean() + for t in cfg.targets: + target = TARGETS[t] + for action in target: + action() From numpy-svn at scipy.org Mon Jul 28 02:13:35 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 01:13:35 -0500 (CDT) Subject: [Numpy-svn] r5564 - vendor/tools Message-ID: <20080728061335.8B2A039C65B@scipy.org> Author: cdavid Date: 2008-07-28 01:13:32 -0500 (Mon, 28 Jul 2008) New Revision: 5564 Modified: vendor/tools/nosse.cfg Log: Reenable lapack optimizations flags. Modified: vendor/tools/nosse.cfg =================================================================== --- vendor/tools/nosse.cfg 2008-07-28 06:12:41 UTC (rev 5563) +++ vendor/tools/nosse.cfg 2008-07-28 06:13:32 UTC (rev 5564) @@ -6,5 +6,5 @@ PW = 32 [BUILD_OPTIONS] TARGETS = blas-lapack -#LAPACK_F77FLAGS = -O3,-funroll-loops +LAPACK_F77FLAGS = -O3,-funroll-loops F77 = g77 From numpy-svn at scipy.org Mon Jul 28 16:46:03 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Mon, 28 Jul 2008 15:46:03 -0500 (CDT) Subject: [Numpy-svn] r5565 - in trunk/numpy/ma: . tests Message-ID: <20080728204603.CC3AE39C643@scipy.org> Author: pierregm Date: 2008-07-28 15:45:51 -0500 (Mon, 28 Jul 2008) New Revision: 5565 Modified: trunk/numpy/ma/core.py trunk/numpy/ma/tests/test_core.py Log: * core : prevent ._basedict to be incorrectly propagated Modified: trunk/numpy/ma/core.py =================================================================== --- trunk/numpy/ma/core.py 2008-07-28 06:13:32 UTC (rev 5564) +++ trunk/numpy/ma/core.py 2008-07-28 20:45:51 UTC (rev 5565) @@ -1322,7 +1322,9 @@ _baseclass = type(obj) else: _baseclass = ndarray - _basedict = getattr(obj, '_basedict', getattr(obj, '__dict__',{})) + # We need to copy the _basedict to avoid backward propagation + _basedict = {} + _basedict.update(getattr(obj, '_basedict', getattr(obj, '__dict__',{}))) _dict = dict(_fill_value=getattr(obj, '_fill_value', None), _hardmask=getattr(obj, '_hardmask', False), _sharedmask=getattr(obj, '_sharedmask', False), Modified: trunk/numpy/ma/tests/test_core.py =================================================================== --- trunk/numpy/ma/tests/test_core.py 2008-07-28 06:13:32 UTC (rev 5564) +++ trunk/numpy/ma/tests/test_core.py 2008-07-28 20:45:51 UTC (rev 5565) @@ -436,6 +436,16 @@ assert_equal(flexi.filled(1), np.array([(1, '1', 1.)], dtype=flexi.dtype)) + + def test_basedict_propagation(self): + "Checks that basedict isn't back-propagated" + x = array([1,2,3,], dtype=float) + x._basedict['info'] = '???' + y = x.copy() + assert_equal(y._basedict['info'],'???') + y._basedict['info'] = '!!!' + assert_equal(x._basedict['info'], '???') + #------------------------------------------------------------------------------ class TestMaskedArrayArithmetic(TestCase): @@ -509,7 +519,6 @@ z = x/y[:,None] assert_equal(z, [[-1.,-1.,-1.], [3.,4.,5.]]) assert_equal(z.mask, [[1,1,1],[0,0,0]]) - def test_mixed_arithmetic(self): "Tests mixed arithmetics." From numpy-svn at scipy.org Tue Jul 29 03:02:16 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 29 Jul 2008 02:02:16 -0500 (CDT) Subject: [Numpy-svn] r5566 - in trunk/numpy: core distutils Message-ID: <20080729070216.70EDD39C7DE@scipy.org> Author: cdavid Date: 2008-07-29 02:02:09 -0500 (Tue, 29 Jul 2008) New Revision: 5566 Modified: trunk/numpy/core/SConscript trunk/numpy/distutils/misc_util.py Log: Handle VS 2008 in msvc_runtime_library. Modified: trunk/numpy/core/SConscript =================================================================== --- trunk/numpy/core/SConscript 2008-07-28 20:45:51 UTC (rev 5565) +++ trunk/numpy/core/SConscript 2008-07-29 07:02:09 UTC (rev 5566) @@ -1,4 +1,4 @@ -# Last Change: Sun Jul 06 01:00 PM 2008 J +# Last Change: Mon Jul 28 03:00 PM 2008 J # vim:syntax=python import os import sys Modified: trunk/numpy/distutils/misc_util.py =================================================================== --- trunk/numpy/distutils/misc_util.py 2008-07-28 20:45:51 UTC (rev 5565) +++ trunk/numpy/distutils/misc_util.py 2008-07-29 07:02:09 UTC (rev 5566) @@ -326,6 +326,7 @@ lib = {'1300' : 'msvcr70', # MSVC 7.0 '1310' : 'msvcr71', # MSVC 7.1 '1400' : 'msvcr80', # MSVC 8 + '1500' : 'msvcr90', # MSVC 9 (VS 2008) }.get(msc_ver, None) else: lib = None From numpy-svn at scipy.org Tue Jul 29 18:49:51 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Tue, 29 Jul 2008 17:49:51 -0500 (CDT) Subject: [Numpy-svn] r5567 - trunk/numpy/ma Message-ID: <20080729224951.BBDA039C2E4@scipy.org> Author: rkern Date: 2008-07-29 17:49:45 -0500 (Tue, 29 Jul 2008) New Revision: 5567 Modified: trunk/numpy/ma/extras.py Log: BUG: missing import. Modified: trunk/numpy/ma/extras.py =================================================================== --- trunk/numpy/ma/extras.py 2008-07-29 07:02:09 UTC (rev 5566) +++ trunk/numpy/ma/extras.py 2008-07-29 22:49:45 UTC (rev 5567) @@ -28,6 +28,7 @@ ] from itertools import groupby +import warnings import core from core import MaskedArray, MAError, add, array, asarray, concatenate, count,\ From numpy-svn at scipy.org Wed Jul 30 03:31:10 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 02:31:10 -0500 (CDT) Subject: [Numpy-svn] r5568 - trunk/numpy/distutils/command Message-ID: <20080730073110.69B0E39C793@scipy.org> Author: cdavid Date: 2008-07-30 02:31:06 -0500 (Wed, 30 Jul 2008) New Revision: 5568 Modified: trunk/numpy/distutils/command/scons.py Log: Require 0.9.0 for numscons. Modified: trunk/numpy/distutils/command/scons.py =================================================================== --- trunk/numpy/distutils/command/scons.py 2008-07-29 22:49:45 UTC (rev 5567) +++ trunk/numpy/distutils/command/scons.py 2008-07-30 07:31:06 UTC (rev 5568) @@ -341,7 +341,7 @@ "this package " % str(e)) try: - minver = "0.8.2" + minver = "0.9.0" from numscons import get_version if get_version() < minver: raise ValueError() From numpy-svn at scipy.org Wed Jul 30 03:33:52 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 02:33:52 -0500 (CDT) Subject: [Numpy-svn] r5569 - trunk/numpy/core Message-ID: <20080730073352.2C82039C260@scipy.org> Author: cdavid Date: 2008-07-30 02:33:48 -0500 (Wed, 30 Jul 2008) New Revision: 5569 Modified: trunk/numpy/core/scons_support.py Log: Do not use numscons rsplit (python >= 2.4 required for numpy >= 1.2.) Modified: trunk/numpy/core/scons_support.py =================================================================== --- trunk/numpy/core/scons_support.py 2008-07-30 07:31:06 UTC (rev 5568) +++ trunk/numpy/core/scons_support.py 2008-07-30 07:33:48 UTC (rev 5569) @@ -1,4 +1,4 @@ -#! Last Change: Thu Jun 12 02:00 PM 2008 J +#! Last Change: Wed Jul 30 02:00 PM 2008 J """Code to support special facilities to scons which are only useful for numpy.core, hence not put into numpy.distutils.scons""" @@ -15,7 +15,6 @@ do_generate_api as nowrap_do_generate_ufunc_api from numscons.numdist import process_c_str as process_str -from numscons.core.utils import rsplit, isstring import SCons.Node import SCons @@ -23,7 +22,7 @@ from SCons.Action import Action def split_ext(string): - sp = rsplit(string, '.', 1) + sp = string.rsplit( '.', 1) if len(sp) == 1: return (sp[0], '') else: From numpy-svn at scipy.org Wed Jul 30 04:22:45 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 03:22:45 -0500 (CDT) Subject: [Numpy-svn] r5570 - trunk/numpy/distutils/command Message-ID: <20080730082245.C12E039C11D@scipy.org> Author: cdavid Date: 2008-07-30 03:22:42 -0500 (Wed, 30 Jul 2008) New Revision: 5570 Modified: trunk/numpy/distutils/command/scons.py Log: Add log-level option to scons command. Modified: trunk/numpy/distutils/command/scons.py =================================================================== --- trunk/numpy/distutils/command/scons.py 2008-07-30 07:33:48 UTC (rev 5569) +++ trunk/numpy/distutils/command/scons.py 2008-07-30 08:22:42 UTC (rev 5570) @@ -242,6 +242,8 @@ '(absolute) to look for scons tools'), ('silent=', None, 'specify whether scons output should less verbose'\ '(1), silent (2), super silent (3) or not (0, default)'), + ('log-level=', None, 'specify log level for numscons. Any value valid '\ + 'for the logging python module is valid'), ('package-list=', None, 'If specified, only run scons on the given '\ 'packages (example: --package-list=scipy.cluster). If empty, '\ 'no package is built')] @@ -260,6 +262,7 @@ self.scons_fcompiler = None self.package_list = None + self.log_level = None def finalize_options(self): old_build_ext.finalize_options(self) @@ -399,6 +402,7 @@ cmd.append('scons_tool_path="%s"' % self.scons_tool_path) cmd.append('src_dir="%s"' % pdirname(sconscript)) cmd.append('pkg_name="%s"' % pkg_name) + cmd.append('log_level=%s' % self.log_level) #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib, # pdirname(sconscript)))) cmd.append('distutils_libdir=%s' % From numpy-svn at scipy.org Wed Jul 30 05:36:43 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 04:36:43 -0500 (CDT) Subject: [Numpy-svn] r5571 - trunk/numpy/distutils/command Message-ID: <20080730093643.E639639C11D@scipy.org> Author: cdavid Date: 2008-07-30 04:36:40 -0500 (Wed, 30 Jul 2008) New Revision: 5571 Modified: trunk/numpy/distutils/command/scons.py Log: More explicit message wrt log level. Modified: trunk/numpy/distutils/command/scons.py =================================================================== --- trunk/numpy/distutils/command/scons.py 2008-07-30 08:22:42 UTC (rev 5570) +++ trunk/numpy/distutils/command/scons.py 2008-07-30 09:36:40 UTC (rev 5571) @@ -262,8 +262,10 @@ self.scons_fcompiler = None self.package_list = None - self.log_level = None + # Only critical things + self.log_level = 50 + def finalize_options(self): old_build_ext.finalize_options(self) if self.distribution.has_scons_scripts(): @@ -439,7 +441,11 @@ st = os.system(cmdstr) if st: print "status is %d" % st - raise DistutilsExecError("Error while executing scons command "\ - "%s (see above)" % cmdstr) + msg = "Error while executing scons command %s (see above)" \ + % cmdstr + msg += """ +Try executing the scons command with --log-level option for more detailed +output, for example --log-level=0; the lowest, the more detailed""" + raise DistutilsExecError(msg) if post_hook: post_hook() From numpy-svn at scipy.org Wed Jul 30 16:22:26 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 15:22:26 -0500 (CDT) Subject: [Numpy-svn] r5572 - trunk/numpy/testing Message-ID: <20080730202226.EACEF39C185@scipy.org> Author: alan.mcintyre Date: 2008-07-30 15:22:24 -0500 (Wed, 30 Jul 2008) New Revision: 5572 Modified: trunk/numpy/testing/numpytest.py Log: Removed unused import of glob. Modified: trunk/numpy/testing/numpytest.py =================================================================== --- trunk/numpy/testing/numpytest.py 2008-07-30 09:36:40 UTC (rev 5571) +++ trunk/numpy/testing/numpytest.py 2008-07-30 20:22:24 UTC (rev 5572) @@ -2,7 +2,6 @@ import re import sys import imp -import glob import types import shlex import unittest From numpy-svn at scipy.org Wed Jul 30 16:27:25 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 15:27:25 -0500 (CDT) Subject: [Numpy-svn] r5573 - trunk/numpy/testing Message-ID: <20080730202725.D507439C100@scipy.org> Author: alan.mcintyre Date: 2008-07-30 15:27:23 -0500 (Wed, 30 Jul 2008) New Revision: 5573 Modified: trunk/numpy/testing/utils.py Log: Delay import of difflib to reduce startup time. Modified: trunk/numpy/testing/utils.py =================================================================== --- trunk/numpy/testing/utils.py 2008-07-30 20:22:24 UTC (rev 5572) +++ trunk/numpy/testing/utils.py 2008-07-30 20:27:23 UTC (rev 5573) @@ -5,7 +5,6 @@ import os import sys import re -import difflib import operator from inspect import isfunction from nosetester import import_nose @@ -282,6 +281,9 @@ exec astr in dict def assert_string_equal(actual, desired): + # delay import of difflib to reduce startup time + import difflib + assert isinstance(actual, str),`type(actual)` assert isinstance(desired, str),`type(desired)` if re.match(r'\A'+desired+r'\Z', actual, re.M): return From numpy-svn at scipy.org Wed Jul 30 16:36:37 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 15:36:37 -0500 (CDT) Subject: [Numpy-svn] r5574 - trunk/numpy/testing Message-ID: <20080730203637.3C41D39C2ED@scipy.org> Author: alan.mcintyre Date: 2008-07-30 15:36:33 -0500 (Wed, 30 Jul 2008) New Revision: 5574 Modified: trunk/numpy/testing/numpytest.py Log: Delay import of shlex to reduce startup time. Modified: trunk/numpy/testing/numpytest.py =================================================================== --- trunk/numpy/testing/numpytest.py 2008-07-30 20:27:23 UTC (rev 5573) +++ trunk/numpy/testing/numpytest.py 2008-07-30 20:36:33 UTC (rev 5574) @@ -3,7 +3,6 @@ import sys import imp import types -import shlex import unittest import traceback import warnings @@ -624,6 +623,10 @@ """ Run Numpy module test suite with level and verbosity taken from sys.argv. Requires optparse module. """ + + # delayed import of shlex to reduce startup time + import shlex + try: from optparse import OptionParser except ImportError: From numpy-svn at scipy.org Wed Jul 30 16:50:22 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 15:50:22 -0500 (CDT) Subject: [Numpy-svn] r5575 - trunk/numpy/testing Message-ID: <20080730205022.9B16B39C2ED@scipy.org> Author: alan.mcintyre Date: 2008-07-30 15:50:20 -0500 (Wed, 30 Jul 2008) New Revision: 5575 Modified: trunk/numpy/testing/utils.py Log: Delay import from inspect to reduce startup time. Modified: trunk/numpy/testing/utils.py =================================================================== --- trunk/numpy/testing/utils.py 2008-07-30 20:36:33 UTC (rev 5574) +++ trunk/numpy/testing/utils.py 2008-07-30 20:50:20 UTC (rev 5575) @@ -6,7 +6,6 @@ import sys import re import operator -from inspect import isfunction from nosetester import import_nose __all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal', @@ -368,6 +367,10 @@ else: testmatch = re.compile(testmatch) cls_attr = cls.__dict__ + + # delayed import to reduce startup time + from inspect import isfunction + methods = filter(isfunction, cls_attr.values()) for function in methods: try: From numpy-svn at scipy.org Wed Jul 30 17:13:05 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Wed, 30 Jul 2008 16:13:05 -0500 (CDT) Subject: [Numpy-svn] r5576 - trunk/numpy/lib Message-ID: <20080730211305.A8A0039C825@scipy.org> Author: stefan Date: 2008-07-30 16:12:48 -0500 (Wed, 30 Jul 2008) New Revision: 5576 Modified: trunk/numpy/lib/io.py Log: Fix string type comparisons. Modified: trunk/numpy/lib/io.py =================================================================== --- trunk/numpy/lib/io.py 2008-07-30 20:50:20 UTC (rev 5575) +++ trunk/numpy/lib/io.py 2008-07-30 21:12:48 UTC (rev 5576) @@ -8,7 +8,6 @@ import numpy as np import format import cStringIO -import tempfile import os import itertools @@ -109,7 +108,7 @@ ------ IOError """ - if isinstance(file, type("")): + if isinstance(file, basestring): fid = _file(file,"rb") else: fid = file @@ -148,7 +147,7 @@ np.save('myfile', a) a = np.load('myfile.npy') """ - if isinstance(file, str): + if isinstance(file, basestring): if not file.endswith('.npy'): file = file + '.npy' fid = open(file, "wb") @@ -171,7 +170,7 @@ # component of the so-called standard library. import zipfile - if isinstance(file, str): + if isinstance(file, basestring): if not file.endswith('.npz'): file = file + '.npz' @@ -186,6 +185,7 @@ # Place to write temporary .npy files # before storing them in the zip + import tempfile direc = tempfile.gettempdir() todel = [] From numpy-svn at scipy.org Thu Jul 31 10:12:58 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 09:12:58 -0500 (CDT) Subject: [Numpy-svn] r5577 - trunk Message-ID: <20080731141258.BD95439C260@scipy.org> Author: cdavid Date: 2008-07-31 09:12:52 -0500 (Thu, 31 Jul 2008) New Revision: 5577 Removed: trunk/test.sh Log: Remove test.sh script which is a leftover from scons branch. Deleted: trunk/test.sh =================================================================== --- trunk/test.sh 2008-07-30 21:12:48 UTC (rev 5576) +++ trunk/test.sh 2008-07-31 14:12:52 UTC (rev 5577) @@ -1,18 +0,0 @@ -# PREFIX=$PWD -# rm -rf $PREFIX/build -# rm -rf $PREFIX/tmp -# MKL=None python setupscons.py scons --jobs=4 install --prefix=$PREFIX/tmp -# (cd $PREFIX/tmp && PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python -c "import numpy; print numpy; numpy.test(level = 9999); numpy.show_config()") - -PREFIX=$PWD -rm -rf $PREFIX/build -rm -rf $PREFIX/tmp -python setupscons.py scons --jobs=4 install --prefix=$PREFIX/tmp -(cd $PREFIX/tmp && PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python -c "import numpy; print numpy; numpy.test(level = 9999); numpy.show_config()") - -# PREFIX=$PWD -# #rm -rf $PREFIX/build -# #rm -rf $PREFIX/tmp -# MKL=None python setupscons.py scons --jobs=4 --silent=2 install --prefix=$PREFIX/tmp -# (cd $PREFIX/tmp/lib/python2.5/site-packages/numpy/distutils/scons/tests/f2pyext/ && \ -# PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python setup.py scons) From numpy-svn at scipy.org Thu Jul 31 10:27:02 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 09:27:02 -0500 (CDT) Subject: [Numpy-svn] r5578 - trunk/numpy/distutils/command Message-ID: <20080731142702.C1E8339C2EB@scipy.org> Author: cdavid Date: 2008-07-31 09:26:58 -0500 (Thu, 31 Jul 2008) New Revision: 5578 Modified: trunk/numpy/distutils/command/scons.py Log: Handle inplace build option for numscons. Modified: trunk/numpy/distutils/command/scons.py =================================================================== --- trunk/numpy/distutils/command/scons.py 2008-07-31 14:12:52 UTC (rev 5577) +++ trunk/numpy/distutils/command/scons.py 2008-07-31 14:26:58 UTC (rev 5578) @@ -238,6 +238,7 @@ user_options = old_build_ext.user_options + \ [('jobs=', None, "specify number of worker threads when executing scons"), + ('inplace', 'i', 'If specified, build in place.'), ('scons-tool-path=', None, 'specify additional path '\ '(absolute) to look for scons tools'), ('silent=', None, 'specify whether scons output should less verbose'\ @@ -262,6 +263,7 @@ self.scons_fcompiler = None self.package_list = None + self.inplace = 0 # Only critical things self.log_level = 50 @@ -401,13 +403,15 @@ cmd = [scons_exec, "-f", sconscript, '-I.'] if self.jobs: cmd.append(" --jobs=%d" % int(self.jobs)) + if self.inplace: + cmd.append("inplace=1") cmd.append('scons_tool_path="%s"' % self.scons_tool_path) cmd.append('src_dir="%s"' % pdirname(sconscript)) cmd.append('pkg_name="%s"' % pkg_name) cmd.append('log_level=%s' % self.log_level) #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib, # pdirname(sconscript)))) - cmd.append('distutils_libdir=%s' % + cmd.append('distutils_libdir=%s' % protect_path(get_distutils_libdir(self, sconscript))) if not self._bypass_distutils_cc: From numpy-svn at scipy.org Thu Jul 31 11:18:14 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 10:18:14 -0500 (CDT) Subject: [Numpy-svn] r5579 - in trunk/numpy/distutils: . command Message-ID: <20080731151814.DB1E239C24E@scipy.org> Author: cdavid Date: 2008-07-31 10:18:08 -0500 (Thu, 31 Jul 2008) New Revision: 5579 Modified: trunk/numpy/distutils/command/scons.py trunk/numpy/distutils/misc_util.py Log: Make it possible to execute post/pre hooks in scons command even when no scons script is used. Modified: trunk/numpy/distutils/command/scons.py =================================================================== --- trunk/numpy/distutils/command/scons.py 2008-07-31 14:26:58 UTC (rev 5578) +++ trunk/numpy/distutils/command/scons.py 2008-07-31 15:18:08 UTC (rev 5579) @@ -232,6 +232,7 @@ return False __NUMPY_SETUP__ = False +# XXX: this is a giantic mess. Refactor this at some point. class scons(old_build_ext): # XXX: add an option to the scons command for configuration (auto/force/cache). description = "Scons builder" @@ -400,56 +401,57 @@ if pre_hook: pre_hook() - cmd = [scons_exec, "-f", sconscript, '-I.'] - if self.jobs: - cmd.append(" --jobs=%d" % int(self.jobs)) - if self.inplace: - cmd.append("inplace=1") - cmd.append('scons_tool_path="%s"' % self.scons_tool_path) - cmd.append('src_dir="%s"' % pdirname(sconscript)) - cmd.append('pkg_name="%s"' % pkg_name) - cmd.append('log_level=%s' % self.log_level) - #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib, - # pdirname(sconscript)))) - cmd.append('distutils_libdir=%s' % - protect_path(get_distutils_libdir(self, sconscript))) + if sconscript: + cmd = [scons_exec, "-f", sconscript, '-I.'] + if self.jobs: + cmd.append(" --jobs=%d" % int(self.jobs)) + if self.inplace: + cmd.append("inplace=1") + cmd.append('scons_tool_path="%s"' % self.scons_tool_path) + cmd.append('src_dir="%s"' % pdirname(sconscript)) + cmd.append('pkg_name="%s"' % pkg_name) + cmd.append('log_level=%s' % self.log_level) + #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib, + # pdirname(sconscript)))) + cmd.append('distutils_libdir=%s' % + protect_path(get_distutils_libdir(self, sconscript))) - if not self._bypass_distutils_cc: - cmd.append('cc_opt=%s' % self.scons_compiler) - cmd.append('cc_opt_path=%s' % self.scons_compiler_path) - else: - cmd.append('cc_opt=%s' % self.scons_compiler) + if not self._bypass_distutils_cc: + cmd.append('cc_opt=%s' % self.scons_compiler) + cmd.append('cc_opt_path=%s' % self.scons_compiler_path) + else: + cmd.append('cc_opt=%s' % self.scons_compiler) - if self.fcompiler: - cmd.append('f77_opt=%s' % dist2sconsfc(self.fcompiler)) - cmd.append('f77_opt_path=%s' % protect_path(get_f77_tool_path(self.fcompiler))) + if self.fcompiler: + cmd.append('f77_opt=%s' % dist2sconsfc(self.fcompiler)) + cmd.append('f77_opt_path=%s' % protect_path(get_f77_tool_path(self.fcompiler))) - if self.cxxcompiler: - cmd.append('cxx_opt=%s' % dist2sconscxx(self.cxxcompiler)) - cmd.append('cxx_opt_path=%s' % protect_path(get_cxx_tool_path(self.cxxcompiler))) + if self.cxxcompiler: + cmd.append('cxx_opt=%s' % dist2sconscxx(self.cxxcompiler)) + cmd.append('cxx_opt_path=%s' % protect_path(get_cxx_tool_path(self.cxxcompiler))) - cmd.append('include_bootstrap=%s' % dirl_to_str(get_numpy_include_dirs(sconscript))) - if self.silent: - if int(self.silent) == 2: - cmd.append('-Q') - elif int(self.silent) == 3: - cmd.append('-s') - cmd.append('silent=%d' % int(self.silent)) - cmd.append('bootstrapping=%d' % bootstrap) - cmdstr = ' '.join(cmd) - if int(self.silent) < 1: - log.info("Executing scons command (pkg is %s): %s ", pkg_name, cmdstr) - else: - log.info("======== Executing scons command for pkg %s =========", pkg_name) - st = os.system(cmdstr) - if st: - print "status is %d" % st - msg = "Error while executing scons command %s (see above)" \ - % cmdstr - msg += """ -Try executing the scons command with --log-level option for more detailed -output, for example --log-level=0; the lowest, the more detailed""" - raise DistutilsExecError(msg) + cmd.append('include_bootstrap=%s' % dirl_to_str(get_numpy_include_dirs(sconscript))) + if self.silent: + if int(self.silent) == 2: + cmd.append('-Q') + elif int(self.silent) == 3: + cmd.append('-s') + cmd.append('silent=%d' % int(self.silent)) + cmd.append('bootstrapping=%d' % bootstrap) + cmdstr = ' '.join(cmd) + if int(self.silent) < 1: + log.info("Executing scons command (pkg is %s): %s ", pkg_name, cmdstr) + else: + log.info("======== Executing scons command for pkg %s =========", pkg_name) + st = os.system(cmdstr) + if st: + print "status is %d" % st + msg = "Error while executing scons command %s (see above)" \ + % cmdstr + msg += """ + Try executing the scons command with --log-level option for more detailed + output, for example --log-level=0; the lowest, the more detailed""" + raise DistutilsExecError(msg) if post_hook: post_hook() Modified: trunk/numpy/distutils/misc_util.py =================================================================== --- trunk/numpy/distutils/misc_util.py 2008-07-31 14:26:58 UTC (rev 5578) +++ trunk/numpy/distutils/misc_util.py 2008-07-31 15:18:08 UTC (rev 5579) @@ -1188,7 +1188,10 @@ """Add a sconscript to configuration. pre_hook and post hook should be sequences of callable, which will be - use before and after executing scons. """ + use before and after executing scons. + + sconscript can be None, which can be useful to add only post/pre + hooks.""" if standalone: parent_name = None else: From numpy-svn at scipy.org Thu Jul 31 12:03:42 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 11:03:42 -0500 (CDT) Subject: [Numpy-svn] r5580 - in trunk/numpy: core distutils linalg Message-ID: <20080731160342.0F45439C10E@scipy.org> Author: cdavid Date: 2008-07-31 11:03:32 -0500 (Thu, 31 Jul 2008) New Revision: 5580 Modified: trunk/numpy/core/setupscons.py trunk/numpy/distutils/misc_util.py trunk/numpy/linalg/setupscons.py Log: Remove add_configres function which did nothing... Modified: trunk/numpy/core/setupscons.py =================================================================== --- trunk/numpy/core/setupscons.py 2008-07-31 15:18:08 UTC (rev 5579) +++ trunk/numpy/core/setupscons.py 2008-07-31 16:03:32 UTC (rev 5580) @@ -81,7 +81,6 @@ add_numpyconfig_header() add_array_api() add_ufunc_api() - config.add_configres() config.add_sconscript('SConstruct', post_hook = add_generated_files, Modified: trunk/numpy/distutils/misc_util.py =================================================================== --- trunk/numpy/distutils/misc_util.py 2008-07-31 15:18:08 UTC (rev 5579) +++ trunk/numpy/distutils/misc_util.py 2008-07-31 16:03:32 UTC (rev 5580) @@ -1229,11 +1229,6 @@ # options in distutils command. self.add_extension('', sources = []) - def add_configres(self): - from numscons import get_scons_configres_dir, get_scons_configres_filename - file = os.path.join(get_scons_configres_dir(), self.local_path, - get_scons_configres_filename()) - def add_scripts(self,*files): """Add scripts to configuration. """ Modified: trunk/numpy/linalg/setupscons.py =================================================================== --- trunk/numpy/linalg/setupscons.py 2008-07-31 15:18:08 UTC (rev 5579) +++ trunk/numpy/linalg/setupscons.py 2008-07-31 16:03:32 UTC (rev 5580) @@ -10,8 +10,7 @@ source_files = ['lapack_litemodule.c', 'zlapack_lite.c', 'dlapack_lite.c', 'blas_lite.c', 'dlamch.c', - 'f2c_lite.c','f2c.h'], - post_hook = config.add_configres) + 'f2c_lite.c','f2c.h']) return config From numpy-svn at scipy.org Thu Jul 31 12:07:08 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 11:07:08 -0500 (CDT) Subject: [Numpy-svn] r5581 - in trunk/numpy: core distutils Message-ID: <20080731160708.E596739C769@scipy.org> Author: cdavid Date: 2008-07-31 11:07:04 -0500 (Thu, 31 Jul 2008) New Revision: 5581 Modified: trunk/numpy/core/setupscons.py trunk/numpy/distutils/misc_util.py Log: Change API for pre/post hooks: they should be able to take arbitrary arguments. Modified: trunk/numpy/core/setupscons.py =================================================================== --- trunk/numpy/core/setupscons.py 2008-07-31 16:03:32 UTC (rev 5580) +++ trunk/numpy/core/setupscons.py 2008-07-31 16:07:04 UTC (rev 5581) @@ -76,7 +76,7 @@ config.add_data_files((header_dir, h_file), (header_dir, t_file)) - def add_generated_files(): + def add_generated_files(*args, **kw): add_config_header() add_numpyconfig_header() add_array_api() Modified: trunk/numpy/distutils/misc_util.py =================================================================== --- trunk/numpy/distutils/misc_util.py 2008-07-31 16:03:32 UTC (rev 5580) +++ trunk/numpy/distutils/misc_util.py 2008-07-31 16:07:04 UTC (rev 5581) @@ -1188,7 +1188,8 @@ """Add a sconscript to configuration. pre_hook and post hook should be sequences of callable, which will be - use before and after executing scons. + use before and after executing scons. The callable should be defined as + callable(*args, **kw). It is ugly, but well, hooks are ugly anyway... sconscript can be None, which can be useful to add only post/pre hooks.""" From numpy-svn at scipy.org Thu Jul 31 12:30:53 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 11:30:53 -0500 (CDT) Subject: [Numpy-svn] r5582 - trunk/numpy/distutils/command Message-ID: <20080731163053.C42E439C985@scipy.org> Author: cdavid Date: 2008-07-31 11:30:44 -0500 (Thu, 31 Jul 2008) New Revision: 5582 Modified: trunk/numpy/distutils/command/scons.py Log: Pass current package name and scons command instance to post hook. Modified: trunk/numpy/distutils/command/scons.py =================================================================== --- trunk/numpy/distutils/command/scons.py 2008-07-31 16:07:04 UTC (rev 5581) +++ trunk/numpy/distutils/command/scons.py 2008-07-31 16:30:44 UTC (rev 5582) @@ -454,4 +454,4 @@ output, for example --log-level=0; the lowest, the more detailed""" raise DistutilsExecError(msg) if post_hook: - post_hook() + post_hook(**{'pkg_name': pkg_name, 'scons_cmd' : self}) From numpy-svn at scipy.org Thu Jul 31 12:31:13 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 11:31:13 -0500 (CDT) Subject: [Numpy-svn] r5583 - trunk/numpy Message-ID: <20080731163113.9301039C9BC@scipy.org> Author: cdavid Date: 2008-07-31 11:31:10 -0500 (Thu, 31 Jul 2008) New Revision: 5583 Modified: trunk/numpy/setupscons.py Log: Handle inplace generation of __config__. Modified: trunk/numpy/setupscons.py =================================================================== --- trunk/numpy/setupscons.py 2008-07-31 16:30:44 UTC (rev 5582) +++ trunk/numpy/setupscons.py 2008-07-31 16:31:10 UTC (rev 5583) @@ -1,8 +1,12 @@ #!/usr/bin/env python +from os.path import join as pjoin def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration - config = Configuration('numpy',parent_package,top_path, setup_name = 'setupscons.py') + from numpy.distutils.misc_util import scons_generate_config_py + + pkgname = 'numpy' + config = Configuration(pkgname,parent_package,top_path, setup_name = 'setupscons.py') config.add_subpackage('distutils') config.add_subpackage('testing') config.add_subpackage('f2py') @@ -16,7 +20,16 @@ config.add_subpackage('ma') config.add_data_dir('doc') config.add_data_dir('tests') - config.scons_make_config_py() # installs __config__.py + + def add_config(*args, **kw): + # Generate __config__, handle inplace issues. + if kw['scons_cmd'].inplace: + target = pjoin(kw['pkg_name'], '__config__.py') + else: + target = pjoin(kw['scons_cmd'].build_lib, kw['pkg_name'], '__config__.py') + scons_generate_config_py(target) + config.add_sconscript(None, post_hook = add_config) + return config if __name__ == '__main__': From numpy-svn at scipy.org Thu Jul 31 12:32:53 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 11:32:53 -0500 (CDT) Subject: [Numpy-svn] r5584 - trunk/numpy Message-ID: <20080731163253.C19AF39C985@scipy.org> Author: cdavid Date: 2008-07-31 11:32:49 -0500 (Thu, 31 Jul 2008) New Revision: 5584 Modified: trunk/numpy/setupscons.py Log: Cosmetic changes. Modified: trunk/numpy/setupscons.py =================================================================== --- trunk/numpy/setupscons.py 2008-07-31 16:31:10 UTC (rev 5583) +++ trunk/numpy/setupscons.py 2008-07-31 16:32:49 UTC (rev 5584) @@ -1,12 +1,13 @@ #!/usr/bin/env python from os.path import join as pjoin -def configuration(parent_package='',top_path=None): +def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration from numpy.distutils.misc_util import scons_generate_config_py pkgname = 'numpy' - config = Configuration(pkgname,parent_package,top_path, setup_name = 'setupscons.py') + config = Configuration(pkgname, parent_package, top_path, + setup_name = 'setupscons.py') config.add_subpackage('distutils') config.add_subpackage('testing') config.add_subpackage('f2py') @@ -26,7 +27,8 @@ if kw['scons_cmd'].inplace: target = pjoin(kw['pkg_name'], '__config__.py') else: - target = pjoin(kw['scons_cmd'].build_lib, kw['pkg_name'], '__config__.py') + target = pjoin(kw['scons_cmd'].build_lib, kw['pkg_name'], + '__config__.py') scons_generate_config_py(target) config.add_sconscript(None, post_hook = add_config) From numpy-svn at scipy.org Thu Jul 31 16:52:33 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 15:52:33 -0500 (CDT) Subject: [Numpy-svn] r5585 - tags Message-ID: <20080731205233.D7D8F39C50C@scipy.org> Author: jarrod.millman Date: 2008-07-31 15:52:30 -0500 (Thu, 31 Jul 2008) New Revision: 5585 Added: tags/1.1.1/ Log: tagging 1.1.1 release Copied: tags/1.1.1 (from rev 5584, branches/1.1.x) From numpy-svn at scipy.org Thu Jul 31 16:54:37 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 15:54:37 -0500 (CDT) Subject: [Numpy-svn] r5586 - tags/1.1.1/numpy Message-ID: <20080731205437.007FB39C50C@scipy.org> Author: jarrod.millman Date: 2008-07-31 15:54:35 -0500 (Thu, 31 Jul 2008) New Revision: 5586 Modified: tags/1.1.1/numpy/version.py Log: updating version information for tag Modified: tags/1.1.1/numpy/version.py =================================================================== --- tags/1.1.1/numpy/version.py 2008-07-31 20:52:30 UTC (rev 5585) +++ tags/1.1.1/numpy/version.py 2008-07-31 20:54:35 UTC (rev 5586) @@ -1,5 +1,5 @@ version='1.1.1' -release=False +release=True if not release: version += '.dev' From numpy-svn at scipy.org Thu Jul 31 16:55:08 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 15:55:08 -0500 (CDT) Subject: [Numpy-svn] r5587 - branches/1.1.x/numpy Message-ID: <20080731205508.1CD3A39C50C@scipy.org> Author: jarrod.millman Date: 2008-07-31 15:55:06 -0500 (Thu, 31 Jul 2008) New Revision: 5587 Modified: branches/1.1.x/numpy/version.py Log: updating version information for branch Modified: branches/1.1.x/numpy/version.py =================================================================== --- branches/1.1.x/numpy/version.py 2008-07-31 20:54:35 UTC (rev 5586) +++ branches/1.1.x/numpy/version.py 2008-07-31 20:55:06 UTC (rev 5587) @@ -1,4 +1,4 @@ -version='1.1.1' +version='1.1.2' release=False if not release: From numpy-svn at scipy.org Thu Jul 31 19:12:55 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 18:12:55 -0500 (CDT) Subject: [Numpy-svn] r5588 - trunk/numpy/lib Message-ID: <20080731231255.1F22939C089@scipy.org> Author: stefan Date: 2008-07-31 18:12:36 -0500 (Thu, 31 Jul 2008) New Revision: 5588 Modified: trunk/numpy/lib/_datasource.py Log: Defer tempfile import to improve startup time. Modified: trunk/numpy/lib/_datasource.py =================================================================== --- trunk/numpy/lib/_datasource.py 2008-07-31 20:55:06 UTC (rev 5587) +++ trunk/numpy/lib/_datasource.py 2008-07-31 23:12:36 UTC (rev 5588) @@ -35,7 +35,6 @@ __docformat__ = "restructuredtext en" import os -import tempfile from shutil import rmtree from urlparse import urlparse @@ -131,6 +130,7 @@ self._destpath = os.path.abspath(destpath) self._istmpdest = False else: + import tempfile # deferring import to improve startup time self._destpath = tempfile.mkdtemp() self._istmpdest = True From numpy-svn at scipy.org Thu Jul 31 19:20:42 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 18:20:42 -0500 (CDT) Subject: [Numpy-svn] r5589 - trunk/tools/osxbuild Message-ID: <20080731232042.3D3C439C2EB@scipy.org> Author: chris.burns Date: 2008-07-31 18:20:39 -0500 (Thu, 31 Jul 2008) New Revision: 5589 Modified: trunk/tools/osxbuild/build.py Log: Add doc to osxbuild script. Modified: trunk/tools/osxbuild/build.py =================================================================== --- trunk/tools/osxbuild/build.py 2008-07-31 23:12:36 UTC (rev 5588) +++ trunk/tools/osxbuild/build.py 2008-07-31 23:20:39 UTC (rev 5589) @@ -2,6 +2,8 @@ This is a simple script, most of the heavy lifting is done in bdist_mpkg. +To run this script: 'python build.py' + Requires a svn version of numpy is installed, svn is used to revert file changes made to the docs for the end-user install. Installer is built using sudo so file permissions are correct when installed on From numpy-svn at scipy.org Thu Jul 31 19:25:32 2008 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 31 Jul 2008 18:25:32 -0500 (CDT) Subject: [Numpy-svn] r5590 - in branches/1.1.x/tools: . osxbuild osxbuild/docs Message-ID: <20080731232532.BED9039C089@scipy.org> Author: chris.burns Date: 2008-07-31 18:25:28 -0500 (Thu, 31 Jul 2008) New Revision: 5590 Added: branches/1.1.x/tools/osxbuild/ branches/1.1.x/tools/osxbuild/README.txt branches/1.1.x/tools/osxbuild/build.py branches/1.1.x/tools/osxbuild/docs/ branches/1.1.x/tools/osxbuild/docs/README.txt Log: Add osxbuild script to 1.1.x branch. Added: branches/1.1.x/tools/osxbuild/README.txt =================================================================== --- branches/1.1.x/tools/osxbuild/README.txt 2008-07-31 23:20:39 UTC (rev 5589) +++ branches/1.1.x/tools/osxbuild/README.txt 2008-07-31 23:25:28 UTC (rev 5590) @@ -0,0 +1,6 @@ +This directory contains the script to build a universal binary for +OSX. The binaries work on OSX 10.4 and 10.5. + + - bdist_mpkg v0.4.3 is required + +See the docstring in build.py for more details. Added: branches/1.1.x/tools/osxbuild/build.py =================================================================== --- branches/1.1.x/tools/osxbuild/build.py 2008-07-31 23:20:39 UTC (rev 5589) +++ branches/1.1.x/tools/osxbuild/build.py 2008-07-31 23:25:28 UTC (rev 5590) @@ -0,0 +1,104 @@ +"""Python script to build the OSX universal binaries. + +This is a simple script, most of the heavy lifting is done in bdist_mpkg. + +To run this script: 'python build.py' + +Requires a svn version of numpy is installed, svn is used to revert +file changes made to the docs for the end-user install. Installer is +built using sudo so file permissions are correct when installed on +user system. Script will prompt for sudo pwd. + +""" + +import os +import shutil +import subprocess +from getpass import getuser + +SRC_DIR = '../../' + +USER_README = 'docs/README.txt' +DEV_README = SRC_DIR + 'README.txt' + +BUILD_DIR = 'build' +DIST_DIR = 'dist' + +def remove_dirs(): + print 'Removing old build and distribution directories...' + print """The distribution is built as root, so the files have the correct + permissions when installed by the user. Chown them to user for removal.""" + if os.path.exists(BUILD_DIR): + cmd = 'sudo chown -R %s %s' % (getuser(), BUILD_DIR) + shellcmd(cmd) + shutil.rmtree(BUILD_DIR) + if os.path.exists(DIST_DIR): + cmd = 'sudo chown -R %s %s' % (getuser(), DIST_DIR) + shellcmd(cmd) + shutil.rmtree(DIST_DIR) + +def build_dist(): + print 'Building distribution... (using sudo)' + cmd = 'sudo python setupegg.py bdist_mpkg' + shellcmd(cmd) + +def build_dmg(): + print 'Building disk image...' + # Since we removed the dist directory at the start of the script, + # our pkg should be the only file there. + pkg = os.listdir(DIST_DIR)[0] + fn, ext = os.path.splitext(pkg) + dmg = fn + '.dmg' + srcfolder = os.path.join(DIST_DIR, pkg) + dstfolder = os.path.join(DIST_DIR, dmg) + # build disk image + cmd = 'sudo hdiutil create -srcfolder %s %s' % (srcfolder, dstfolder) + shellcmd(cmd) + +def copy_readme(): + """Copy a user README with info regarding the website, instead of + the developer README which tells one how to build the source. + """ + print 'Copy user README.txt for installer.' + shutil.copy(USER_README, DEV_README) + +def revert_readme(): + """Revert the developer README.""" + print 'Reverting README.txt...' + cmd = 'svn revert %s' % DEV_README + shellcmd(cmd) + +def shellcmd(cmd, verbose=True): + """Call a shell command.""" + if verbose: + print cmd + try: + subprocess.check_call(cmd, shell=True) + except subprocess.CalledProcessError, err: + msg = """ + Error while executing a shell command. + %s + """ % str(err) + raise Exception(msg) + +def build(): + # update end-user documentation + copy_readme() + shellcmd("svn stat %s"%DEV_README) + + # change to source directory + cwd = os.getcwd() + os.chdir(SRC_DIR) + + # build distribution + remove_dirs() + build_dist() + build_dmg() + + # change back to original directory + os.chdir(cwd) + # restore developer documentation + revert_readme() + +if __name__ == '__main__': + build() Added: branches/1.1.x/tools/osxbuild/docs/README.txt =================================================================== --- branches/1.1.x/tools/osxbuild/docs/README.txt 2008-07-31 23:20:39 UTC (rev 5589) +++ branches/1.1.x/tools/osxbuild/docs/README.txt 2008-07-31 23:25:28 UTC (rev 5590) @@ -0,0 +1,22 @@ +NumPy is the fundamental package needed for scientific computing with Python. +This package contains: + + * a powerful N-dimensional array object + * sophisticated (broadcasting) functions + * tools for integrating C/C++ and Fortran code + * useful linear algebra, Fourier transform, and random number capabilities. + +It derives from the old Numeric code base and can be used as a replacement for Numeric. It also adds the features introduced by numarray and can be used to replace numarray. + +More information can be found at the website: + +http://scipy.org/NumPy + +After installation, tests can be run with: + +python -c 'import numpy; numpy.test()' + +The most current development version is always available from our +subversion repository: + +http://svn.scipy.org/svn/numpy/trunk