Author: Antonio Cuni <[email protected]>
Branch: 
Changeset: r61093:bed85891f7c2
Date: 2013-02-11 14:53 +0100
http://bitbucket.org/pypy/pypy/changeset/bed85891f7c2/

Log:    merge heads

diff --git a/lib_pypy/numpypy/core/shape_base.py 
b/lib_pypy/numpypy/core/shape_base.py
--- a/lib_pypy/numpypy/core/shape_base.py
+++ b/lib_pypy/numpypy/core/shape_base.py
@@ -272,3 +272,52 @@
     else:
         return _numpypy.concatenate(arrs, 1)
 
+def dstack(tup):
+    """
+    Stack arrays in sequence depth wise (along third axis).
+
+    Takes a sequence of arrays and stack them along the third axis
+    to make a single array. Rebuilds arrays divided by `dsplit`.
+    This is a simple way to stack 2D arrays (images) into a single
+    3D array for processing.
+
+    Parameters
+    ----------
+    tup : sequence of arrays
+        Arrays to stack. All of them must have the same shape along all
+        but the third axis.
+
+    Returns
+    -------
+    stacked : ndarray
+        The array formed by stacking the given arrays.
+
+    See Also
+    --------
+    vstack : Stack along first axis.
+    hstack : Stack along second axis.
+    concatenate : Join arrays.
+    dsplit : Split array along third axis.
+
+    Notes
+    -----
+    Equivalent to ``np.concatenate(tup, axis=2)``.
+
+    Examples
+    --------
+    >>> a = np.array((1,2,3))
+    >>> b = np.array((2,3,4))
+    >>> np.dstack((a,b))
+    array([[[1, 2],
+            [2, 3],
+            [3, 4]]])
+
+    >>> a = np.array([[1],[2],[3]])
+    >>> b = np.array([[2],[3],[4]])
+    >>> np.dstack((a,b))
+    array([[[1, 2]],
+           [[2, 3]],
+           [[3, 4]]])
+
+    """
+    return _numpypy.concatenate(map(atleast_3d,tup),2)
diff --git a/pypy/doc/config/translation.lldebug.txt 
b/pypy/doc/config/translation.lldebug.txt
new file mode 100644
--- /dev/null
+++ b/pypy/doc/config/translation.lldebug.txt
@@ -0,0 +1,1 @@
+Run make lldebug when source is ready
diff --git a/pypy/module/test_lib_pypy/numpypy/core/test_shape_base.py 
b/pypy/module/test_lib_pypy/numpypy/core/test_shape_base.py
--- a/pypy/module/test_lib_pypy/numpypy/core/test_shape_base.py
+++ b/pypy/module/test_lib_pypy/numpypy/core/test_shape_base.py
@@ -1,18 +1,19 @@
 from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
 
+
 class AppTestShapeBase(BaseNumpyAppTest):
 
     def test_atleast_1d(self):
         from numpypy import array, array_equal
         import numpypy as np
         a = np.atleast_1d(1.0)
-        assert np.array_equal(a, [ 1.])
-        
-        x = np.arange(9.0).reshape(3,3)
+        assert np.array_equal(a, [1.])
+
+        x = np.arange(9.0).reshape(3, 3)
         a = np.atleast_1d(x)
-        assert np.array_equal(a, [[ 0.,  1.,  2.],
-                                  [ 3.,  4.,  5.],
-                                  [ 6.,  7.,  8.]])
+        assert np.array_equal(a, [[0.,  1.,  2.],
+                                  [3.,  4.,  5.],
+                                  [6.,  7.,  8.]])
         assert np.atleast_1d(x) is x
 
         a = np.atleast_1d(1, [3, 4])
@@ -23,11 +24,11 @@
     def test_atleast_2d(self):
         import numpypy as np
         a = np.atleast_2d(3.0)
-        assert np.array_equal(a, [[ 3.]])
+        assert np.array_equal(a, [[3.]])
 
         x = np.arange(3.0)
         a = np.atleast_2d(x)
-        assert np.array_equal(a, [[ 0.,  1.,  2.]])
+        assert np.array_equal(a, [[0., 1., 2.]])
 
         a = np.atleast_2d(1, [1, 2], [[1, 2]])
         assert len(a) == 3
@@ -39,12 +40,12 @@
         import numpypy as np
 
         a = np.atleast_3d(3.0)
-        assert np.array_equal(a, [[[ 3.]]])
+        assert np.array_equal(a, [[[3.]]])
 
         x = np.arange(3.0)
         assert np.atleast_3d(x).shape == (1, 3, 1)
 
-        x = np.arange(12.0).reshape(4,3)
+        x = np.arange(12.0).reshape(4, 3)
         assert np.atleast_3d(x).shape == (4, 3, 1)
 
         a = np.atleast_3d([1, 2])
@@ -66,13 +67,13 @@
 
         a = np.array([1, 2, 3])
         b = np.array([2, 3, 4])
-        c = np.vstack((a,b))
+        c = np.vstack((a, b))
         assert np.array_equal(c, [[1, 2, 3],
                                   [2, 3, 4]])
 
         a = np.array([[1], [2], [3]])
         b = np.array([[2], [3], [4]])
-        c = np.vstack((a,b))
+        c = np.vstack((a, b))
         assert np.array_equal(c, [[1],
                                   [2],
                                   [3],
@@ -80,17 +81,83 @@
                                   [3],
                                   [4]])
 
+        for shape1, shape2 in [[(2, 1), (3, 1)],
+                               [(2, 4), [3, 4]]]:
+            a, b = np.ones(shape1), np.ones(shape2)
+            assert np.all(np.vstack((a, b)) ==
+                          np.ones((a.shape[0] + b.shape[0],
+                                   a.shape[1])))
+
+        skip("https://bugs.pypy.org/issue1394";)
+        for shape1, shape2 in [[(3, 2, 4), (7, 2, 4)],
+                               [(0, 2, 7), (10, 2, 7)],
+                               [(0, 2, 7), (0, 2, 7)]]:
+            a, b = np.ones(shape1), np.ones(shape2)
+            assert np.all(np.vstack((a, b)) ==
+                          np.ones((a.shape[0] + b.shape[0],
+                                   a.shape[1],
+                                   a.shape[2])))
+
     def test_hstack(self):
         import numpypy as np
-        a = np.array((1,2,3))
-        b = np.array((2,3,4))
-        c = np.hstack((a,b))
+        a = np.array((1, 2, 3))
+        b = np.array((2, 3, 4))
+        c = np.hstack((a, b))
         assert np.array_equal(c, [1, 2, 3, 2, 3, 4])
-        
-        a = np.array([[1],[2],[3]])
-        b = np.array([[2],[3],[4]])
-        c = np.hstack((a,b))
+
+        a = np.array([[1], [2], [3]])
+        b = np.array([[2], [3], [4]])
+        c = np.hstack((a, b))
         assert np.array_equal(c, [[1, 2],
                                   [2, 3],
                                   [3, 4]])
 
+        for shape1, shape2 in [[(1, 2), (1, 3)],
+                               [(4, 2), (4, 3)]]:
+            a, b = np.ones(shape1), np.ones(shape2)
+            assert np.all(np.hstack((a, b)) ==
+                          np.ones((a.shape[0],
+                                   a.shape[1] + b.shape[1])))
+
+        skip("https://bugs.pypy.org/issue1394";)
+        for shape1, shape2 in [[(2, 3, 4), (2, 7, 4)],
+                               [(1, 4, 7), (1, 10, 7)],
+                               [(1, 4, 7), (1, 0, 7)],
+                               [(1, 0, 7), (1, 0, 7)]]:
+            a, b = np.ones(shape1), np.ones(shape2)
+            assert np.all(np.hstack((a, b)) ==
+                          np.ones((a.shape[0],
+                                   a.shape[1] + b.shape[1],
+                                   a.shape[2])))
+
+    def test_dstack(self):
+        import numpypy as np
+        a = np.array((1, 2, 3))
+        b = np.array((2, 3, 4))
+        c = np.dstack((a, b))
+        assert np.array_equal(c, [[[1, 2], [2, 3], [3, 4]]])
+
+        a = np.array([[1], [2], [3]])
+        b = np.array([[2], [3], [4]])
+        c = np.dstack((a, b))
+        assert np.array_equal(c, [[[1, 2]], [[2, 3]], [[3, 4]]])
+
+        skip("https://bugs.pypy.org/issue1394";)
+        for shape1, shape2 in [[(4, 2, 3), (4, 2, 7)],
+                               [(7, 2, 0), (7, 2, 10)],
+                               [(7, 2, 0), (7, 2, 0)]]:
+            a, b = np.ones(shape1), np.ones(shape2)
+            assert np.all(np.dstack((a, b)) ==
+                          np.ones((a.shape[0],
+                                   a.shape[1],
+                                   a.shape[2] + b.shape[2])))
+
+        for shape1, shape2 in [[(4, 2, 3, 5), (4, 2, 7, 5)],
+                               [(7, 2, 0, 5), (7, 2, 10, 5)],
+                               [(7, 2, 0, 5), (7, 2, 0, 5)]]:
+            a, b = np.ones(shape1), np.ones(shape2)
+            assert np.all(np.dstack((a, b)) ==
+                          np.ones((a.shape[0],
+                                   a.shape[1],
+                                   a.shape[2] + b.shape[2],
+                                   a.shape[3])))
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -3,7 +3,7 @@
 It uses 'pypy/goal/pypy-c' and parts of the rest of the working
 copy.  Usage:
 
-    package.py root-pypy-dir [name-of-archive] [name-of-pypy-c] 
[destination-for-tarball] [pypy-c-path]
+    package.py root-pypy-dir [--nostrip] [name-of-archive] [name-of-pypy-c] 
[destination-for-tarball] [pypy-c-path]
 
 Usually you would do:   package.py ../../.. pypy-VER-PLATFORM
 The output is found in the directory /tmp/usession-YOURNAME/build/.
@@ -44,7 +44,7 @@
         os.system("chmod -R a+rX %s" % basedir)
 
 def package(basedir, name='pypy-nightly', rename_pypy_c='pypy',
-            copy_to_dir = None, override_pypy_c = None):
+            copy_to_dir = None, override_pypy_c = None, nostrip=False):
     basedir = py.path.local(basedir)
     if override_pypy_c is None:
         basename = 'pypy-c'
@@ -124,13 +124,14 @@
         os.chdir(str(builddir))
         #
         # 'strip' fun: see issue #587
-        for source, target in binaries:
-            if sys.platform == 'win32':
-                pass
-            elif sys.platform == 'darwin':
-                os.system("strip -x " + str(bindir.join(target)))    # ignore 
errors
-            else:
-                os.system("strip " + str(bindir.join(target)))    # ignore 
errors
+        if not nostrip:
+            for source, target in binaries:
+                if sys.platform == 'win32':
+                    pass
+                elif sys.platform == 'darwin':
+                    os.system("strip -x " + str(bindir.join(target)))    # 
ignore errors
+                else:
+                    os.system("strip " + str(bindir.join(target)))    # ignore 
errors
         #
         if USE_ZIPFILE_MODULE:
             import zipfile
@@ -166,4 +167,9 @@
         print >>sys.stderr, __doc__
         sys.exit(1)
     else:
-        package(*sys.argv[1:])
+        args = sys.argv[1:]
+        kw = {}
+        if args[0] == '--nostrip':
+            kw['nostrip'] = True
+            args = args[1:]
+        package(*args, **kw)
diff --git a/rpython/config/translationoption.py 
b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -183,6 +183,9 @@
                "When true, enable the use of tagged pointers. "
                "If false, use normal boxing",
                default=False),
+    BoolOption("lldebug",
+               "If true, makes an lldebug build", default=False,
+               cmdline="--lldebug"),
 
     # options for ootype
     OptionDescription("ootype", "Object Oriented Typesystem options", [
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -360,6 +360,8 @@
         extra_opts = []
         if self.config.translation.make_jobs != 1:
             extra_opts += ['-j', str(self.config.translation.make_jobs)]
+        if self.config.translation.lldebug:
+            extra_opts += ["lldebug"]
         self.translator.platform.execute_makefile(self.targetdir,
                                                   extra_opts)
         if shared:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to