[Numpy-svn] r3148 - trunk/numpy/lib

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Sep 13 20:20:59 CDT 2006


Author: oliphant
Date: 2006-09-13 20:20:52 -0500 (Wed, 13 Sep 2006)
New Revision: 3148

Modified:
   trunk/numpy/lib/index_tricks.py
   trunk/numpy/lib/shape_base.py
   trunk/numpy/lib/type_check.py
Log:
Fix column-stack to not transpose 2-d inputs.  Fix iscomplex for strings.  Add deprecation warning for c_

Modified: trunk/numpy/lib/index_tricks.py
===================================================================
--- trunk/numpy/lib/index_tricks.py	2006-09-13 23:55:37 UTC (rev 3147)
+++ trunk/numpy/lib/index_tricks.py	2006-09-14 01:20:52 UTC (rev 3148)
@@ -225,7 +225,7 @@
                 if start is None: start = 0
                 if step is None:
                     step = 1
-                if type(step) is type(1j):
+                if isinstance(step, complex):
                     size = int(abs(step))
                     newobj = function_base.linspace(start, stop, num=size)
                 else:
@@ -281,18 +281,20 @@
 
 r_ = r_class()
 
+import warnings
+
 class c_class(concatenator):
     """Translates slice objects to concatenation along the second axis.
 
-        For example:
-        >>> c_[array([[1],[2],[3]]), array([[4],[5],[6]])]
-        array([[1, 4],
-               [2, 5],
-               [3, 6]])
+       This is deprecated.  Use r_[...,'-1']
     """
     def __init__(self):
         concatenator.__init__(self, -1)
 
+    def __getitem__(self, obj):
+        warnings.warn("c_ is deprecated use r_[...,'-1']")
+        return concatenator.__getitem__(self, obj)
+
 c_ = c_class()
 
 class ndenumerate(object):
@@ -383,9 +385,6 @@
 # Cosmetic changes by T. Oliphant 2001
 #
 #
-# This module provides a convenient method for constructing
-# array indices algorithmically. It provides one importable object,
-# 'index_expression'.
 
 class _index_expression_class(object):
     """

Modified: trunk/numpy/lib/shape_base.py
===================================================================
--- trunk/numpy/lib/shape_base.py	2006-09-13 23:55:37 UTC (rev 3147)
+++ trunk/numpy/lib/shape_base.py	2006-09-14 01:20:52 UTC (rev 3148)
@@ -141,7 +141,7 @@
     """
     res = []
     for ary in arys:
-        res.append(array(ary,copy=False,subok=2,ndmin=2))
+        res.append(array(ary,copy=False,subok=True,ndmin=2))
     if len(res) == 1:
         return res[0]
     else:
@@ -246,10 +246,13 @@
         Description:
             Take a sequence of 1D arrays and stack them as columns
             to make a single 2D array.  All arrays in the sequence
-            must have the same length.
+            must have the same first dimension.  2D arrays are
+            stacked as-is, just like with hstack.  1D arrays are turned
+            into 2D columns first.
+            
         Arguments:
-            tup -- sequence of 1D arrays.  All arrays must have the same
-                   length.
+            tup -- sequence of 1D or 2D arrays.  All arrays must have the same
+                   first dimension.
         Examples:
             >>> import numpy
             >>> a = array((1,2,3))
@@ -260,7 +263,12 @@
                    [3, 4]])
 
     """
-    arrays = map(_nx.transpose,map(atleast_2d,tup))
+    arrays = []
+    for v in tup:
+        arr = array(v,copy=False,subok=True)
+        if arr.ndim < 2:
+            arr = array(arr,copy=False,subok=True,ndmin=2).T
+        arrays.append(arr)
     return _nx.concatenate(arrays,1)
 
 def dstack(tup):

Modified: trunk/numpy/lib/type_check.py
===================================================================
--- trunk/numpy/lib/type_check.py	2006-09-13 23:55:37 UTC (rev 3147)
+++ trunk/numpy/lib/type_check.py	2006-09-14 01:20:52 UTC (rev 3148)
@@ -6,7 +6,7 @@
            'common_type']
 
 import numpy.core.numeric as _nx
-from numpy.core.numeric import asarray, array, isnan, obj2sctype
+from numpy.core.numeric import asarray, array, isnan, obj2sctype, zeros
 from ufunclike import isneginf, isposinf
 
 _typecodes_by_elsize = 'GDFgdfQqLlIiHhBb?'
@@ -68,7 +68,11 @@
 
     For scalars, return a boolean.
     """
-    return imag(x) != 0
+    ax = asarray(x)
+    if issubclass(ax.dtype.type, _nx.complexfloating):
+        return ax.imag != 0
+    res = zeros(ax.shape, bool)
+    return +res  # convet to array-scalar if needed
 
 def isreal(x):
     """Return a boolean array where elements are True if that element



More information about the Numpy-svn mailing list